<template>
	<view class="u-flex u-row-around  gap u-font-xl">
		<view style="margin-left: 50px;" class="u-flex-col u-text-center u-row-center u-flex-wrap u-col-center gap u-font-xl">
			<view v-if="workCenter != '数控车间' && workCenter != '焊接车间' && workCenter != '喷涂车间'">
				<view v-if="reminderSwitch && workCenter != 'EMS总装车间'" class="u-flex u-row-center" style="color: red;font-size: 60rpx;">
					当前状态无法扫码，请先查看文档指导与视频指导，再扫码工作
				</view>
				<view v-else class="u-flex u-row-center" style="color: red;font-size: 60rpx;">
					当前状态可以扫码工作
				</view>
			</view>
			<view class="u-flex u-row-center gap" style="color: red;font-size: 60rpx;" v-if="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'">
				<view>当前机台号：</view>
				<view>{{this.workNum}}</view>
				<view>{{bindingUser.machineName?'('+bindingUser.machineName+')':''}}</view>
				<u-button type="success" :ripple="true" size="mini" @click="workNumClick" class="machineBtn">切换机台号</u-button>
			</view>
			
			<view class="u-flex u-row-center gap" style="color: red;font-size: 60rpx;" v-else>
				<view>当前工序序号：</view>
				<view>{{this.workNum}}</view>
				<view v-if="workCenter == 'EMS总装车间' || workCenter == '总装车间' && this.processName">({{this.processName}})</view>
			</view>
			
			<view class="u-flex u-row-center gap" v-if="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'">
				<view>当前已绑定机台号的员工：</view>
				<!-- <view style="color:#2979ff">{{bindingUser.jobNumber?bindingUser.userName1+'-'+bindingUser.jobNumber:''}}</view>
				<view style="color:#2979ff">{{bindingUser.jobNumber2?','+bindingUser.userName2+'-'+bindingUser.jobNumber2:''}}</view>
				<view style="color:#2979ff">{{bindingUser.jobNumber3?','+bindingUser.userName3+'-'+bindingUser.jobNumber3:''}}</view> -->
				<view style="color:#2979ff">{{bindingUser.jobNumber?bindingUser.jobNumber:''}}{{bindingUser.jobNumber&&bindingUser.jobNumber2 || bindingUser.jobNumber3 || bindingUser.jobNumber4 || bindingUser.jobNumber5?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.jobNumber2?bindingUser.jobNumber2:''}}{{bindingUser.jobNumber2&&bindingUser.jobNumber3 || bindingUser.jobNumber4 || bindingUser.jobNumber5?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.jobNumber3?bindingUser.jobNumber3:''}}{{bindingUser.jobNumber3&&bindingUser.jobNumber4 || bindingUser.jobNumber5?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.jobNumber4?bindingUser.jobNumber4:''}}{{bindingUser.jobNumber4&&bindingUser.jobNumber5?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.jobNumber5?bindingUser.jobNumber5:''}}</view>
			</view>
			
			<!-- <view class="u-flex u-row-center gap" v-if="workCenter == '喷涂车间'">
				<view>当前已绑定机台号的员工：</view>
				<view style="color:#2979ff">{{bindingUser.user1?bindingUser.user1:''}}{{bindingUser.user2?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.user2?bindingUser.user2:''}}{{bindingUser.user3?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.user3?bindingUser.user3:''}}{{bindingUser.user4?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.user4?bindingUser.user4:''}}{{bindingUser.user5?',':''}}</view>
				<view style="color:#2979ff">{{bindingUser.user5?bindingUser.user5:''}}</view>
			</view> -->
			
			<view class="updateData" v-if="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'"><u-button type="mini" @click="updateBindingUser">点击更新</u-button></view>
			
			<view class="u-flex u-row-center gap">
				<view>当前工段编号：</view>
				<view>{{this.sectionNum}}</view>
			</view>
			
			<view class="u-flex u-row-center gap">
				<view >线体名称:  </view> <view style="margin-right: 30rpx; color:red"> {{this.address}}  </view>
				<view>线体简称:  </view> <view style="color:red"> {{this.sectionAbbreviation}}</view>
			</view>
			
			<view class="u-flex u-row-center gap" v-if="workCenter == 'EMS总装车间' || workCenter == '总装车间'">
				<view>(排产工单：</view>
				<view>{{this.workOrderNoType}}</view>
				<view>,编码：</view>
				<view>{{this.technologyNo}})</view>
			</view>
			
			<view class="u-flex u-row-center gap" v-if="workNumList.length">
				<view>切换当前工序序号：</view>
				<u-radio-group v-model="workNum" size="50" @change="radioGroupChange">
					<u-radio 
						v-for="(item, index) in workNumList" :key="index"
						:name="item.name"
						:disabled="item.disabled"
					>
						{{item.name}}
					</u-radio>
				</u-radio-group>
			</view>
			<!-- 数控车间扫码 -->
			<view v-if="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'">
				<view class="gap">扫码/手动输入设备条码</view>
				<view :class="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'?'cncclass':''">
					<u-form :model="machineForm" style="width: 300px;" class="gap">
						
						<u-radio-group v-model="cncScanType" @change="radioGroupChange" v-if="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'">
							<u-radio 
								@change="radioChange" 
								v-for="(item, index) in cnclist" :key="index" 
								:name="item.name"
								:disabled="item.disabled"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
						<!-- 批量扫码 -->
						<div v-if="cncScanType == '批量扫码' && workCenter !== '喷涂车间'">
							<div style="width: 1270rpx;">
							<div v-for="(item, index) in  batchList" style="display: flex;justify-content: flex-start;align-items: center; margin-bottom: 10rpx;">
								<div style="width: 420rpx;margin-right: 7rpx;">
							        <u-input
							        	:focus="autofocus"
							        	 v-model="item.deviceBarcode" 
							        	 ref="inputValues" 	
							        	 :disabled="disabledMachine"
							        	 placeholder="请使用扫码枪扫设备条码" type="text" border @input="batchInput(item.deviceBarcode, index)"/>
								</div>
								<div style="width: 200rpx;margin-right: 7rpx;">
							         <u-input
							             v-model="item.completionQuantity"
							             placeholder="零件数量" 
							             ref="completionQuantity" 
							             type="text" 
							             border/>
								</div>
								<div v-if="item.upperLimit >= 1" style="width: 190rpx;margin-right: 7rpx;">
								    <u-input
								    	 v-model="item.jobNumber1" 
								    	 placeholder="员工工号"
								    	 type="text" 
								    	 border  
										 />
								</div>
								<div v-if="item.upperLimit >= 2" style="width: 190rpx;margin-right: 7rpx;">
								     <u-input
								     	 v-model="item.jobNumber2" 
								     	 placeholder="员工工号" 
								     	 type="text" 
								     	 border />
								</div>
								<div v-if="item.upperLimit >= 3" style="width: 190rpx;margin-right: 7rpx;">
								    <u-input
								    	 v-model="item.jobNumber3" 
								    	 placeholder="员工工号" 
								    	 type="text"
								    	 border/>
								</div>
							</div>
							</div>
								<u-button style="margin-right: 4rpx;" type="success" size="mini" @click="addBatch()">添加</u-button>
								<u-button type="error" size="mini" @click="delBatch()" >删除</u-button>
						</div>
					    <div  v-if="cncScanType == '手动输入' || cncScanType == '扫码输入'">
					    	<div style="display: flex;flex-direction: row;align-items: center;" class="gap" v-if="cncScanType == '手动输入'">
					    		<u-input :focus="autofocus"
					    			 v-model="machineForm.deviceBarcode" 
					    			 ref="inputValues" 
					    			 :disabled="disabledMachine"
					    			 placeholder="请使用扫码枪扫码/手动输入设备条码" type="text" border/>
					    		<u-button type="success" :ripple="true" size="mini" @click="circlemachine" style="margin-left: 5px;">提交</u-button>
					    	</div>
					    	<u-input
					    		:focus="autofocus"
					    		 v-model="machineForm.deviceBarcode" 
					    		 ref="inputValues" 
					    		 :disabled="disabledMachine"
					    		 placeholder="请使用扫码枪扫码/手动输入设备条码" type="text" border class="gap" @input="circlemachine" v-else/>
					    	
					    	<view style="font-size: 10rpx;color: #666666;">提示：如果扫码后无反应，请检查输入框是否获得焦点</view>
					    	
					    	<div class="cncJobnumber" v-if="cncUnDone">
					    		<u-input
					    			 v-model="machineBindForm.jobNumber1" 
					    			 placeholder="员工工号" 
					    			 type="text" 
					    			 border 
					    			 class="gap"
					    			 v-if="upperLimit >= 1"/>
					    		<u-input
					    			 v-model="machineBindForm.jobNumber2" 
					    			 placeholder="员工工号" 
					    			 type="text" 
					    			 border 
					    			 class="gap"
					    			 v-if="upperLimit >= 2"/>
					    		<u-input
					    			 v-model="machineBindForm.jobNumber3" 
					    			 placeholder="员工工号" 
					    			 type="text" 
					    			 border 
					    			 class="gap"
					    			 v-if="upperLimit >= 3"/>
								 <u-input
								 	 v-model="machineBindForm.jobNumber4" 
								 	 placeholder="员工工号" 
								 	 type="text" 
								 	 border 
								 	 class="gap"
								 	 v-if="upperLimit >= 4"/>
								<u-input
									 v-model="machineBindForm.jobNumber5" 
									 placeholder="员工工号" 
									 type="text" 
									 border 
									 class="gap"
									 v-if="upperLimit >= 5"/>
									 
					    	</div>
					    	<u-button type="success" class="gap" v-if="cncUnDone" @click="machineBindAndUnbind">绑定当前机台</u-button>
					    	<u-input
					    		v-model="machineForm.completionQuantity"
					    		placeholder="请输入零件数量" 
					    		ref="completionQuantity" 
					    		type="text" 
					    		border
					    		class="gap"
					    		style="margin: 30px 0;"
					    		v-if="!cncUnDone"/>
					    </div>
							
						<u-button type="success" class="gap" @click="getcncBinder" v-if="!cncUnDone && cncScanType !== '批量扫码'" :disabled="step != 2">上传条码</u-button>
						<u-button type="success" class="gap" @click="batchBinder" v-if="cncScanType == '批量扫码'" :disabled="batchDisabled" >上传条码</u-button>
						<u-toast ref="uToast" />
						<!-- 2023-7-12 废弃 -->
						<u-modal v-model="showCNCbinder" :show-cancel-button="true" :content="contentCNCbinder"  @confirm="handleBarcode" @cancel="showCNCbinder = false"></u-modal>
					</u-form>
					<div v-if="cncScanType !== '批量扫码'">
						<div style="margin-left: 20px;" v-if="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'">
							<u-steps :list="numList" :current="step" direction="column" :active-color="'#19be6b'"></u-steps>
						</div>
					</div>
					
				</view>
				
				<view class="gap1">
					<view>异常报警</view>	
					<u-form :model="errorForm" style="width: 355px; height: 115rpx;" class="gap">
						<u-radio-group v-model="errorForm.value">
							<u-radio 
								@change="machineRadioChange" 
								v-for="(item, index) in machineError" :key="index" 
								:name="item.name"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
						<u-form-item label="异常小类:" v-if="errorMins.length" :border-bottom="false" label-width="130">
							<u-radio-group v-model="errorForm.abnormalNameMin">
								<u-radio 
									@change="nameMinRadioChange" 
									v-for="(item, index) in errorMins" :key="index" 
									:name="item.name"
								>
									{{item.name}}
								</u-radio>
							</u-radio-group>
						</u-form-item>
						<u-input
							v-model="errorForm.deviceBarcode"
							placeholder="请手动/使用扫码枪扫码输入设备条码" 
							ref="values" 
							type="text" 
							border
							class="gap"/>
						<view style="font-size: 10rpx;color: #666666;">提示：如果扫码后无反应，请检查输入框是否获得焦点</view>
						<u-input
							v-model="errorForm.content"
							placeholder="请输入异常描述(最多50个字)" 
							ref="values" 
							type="textarea"
							maxlength="50"
							border
							class="gap"/>
						<u-button
								  style="width:300px;height:40px;"
								  type="success"
								  class="gap"
								  @click="handleError1">
								  异常上传
						</u-button>
					</u-form>
				</view>
			</view>
			<!-- EMS总装车间扫码 -->
			<view v-else-if="workCenter == 'EMS总装车间' || workCenter == '总装车间'">
				<view class="gap">工件条形码编号扫码输入</view>
				<view>
					<u-form :model="emsForm" style="width: 1200rpx;" class="gap">
						<u-form-item label="机柜条码" label-width="150rpx" required>
							<u-input :focus="autofocusdevice"
								 v-model="emsForm.deviceBardcode" 
								 :disabled="disabledems"
								 ref="inputValues" 
								 placeholder=" "
								 border 
								 @input="circleDecEms"/>
						    <span v-if="workCenter == '总装车间' && lineType == 1"></span>
							<u-button v-else slot="right" type="success" :ripple="true" size="mini" @click="showdeviceBardcodes = true" class="machineBtn">有效条码</u-button>
							<u-select v-model="showdeviceBardcodes" mode="mutil-column-auto" :list="deviceBardcodeList" label-name="sn"></u-select>
						</u-form-item>
						<view style="font-size: 10rpx;color: #666666;">提示：如果扫码后无反应，请检查输入框是否获得焦点</view>
						
						
						<u-form-item label="临技条码" label-width="150rpx" required v-if="linJiObj && linJiObj.processOrder == parseInt(this.workNum) && linJiisfirst">
							<u-input
								 v-model="deviceDarcodeLinJiNew" 
								 :disabled="disabledemsLJ"
								 ref="focusLinJiNew1" 
								 placeholder=" " 
								 type="text" 
								 border 
								 @input="circleDecEmsLinJiNew"/>
						</u-form-item>
						<view style="font-size: 10rpx;color: #666666;" v-if="linJiObj && linJiObj.processOrder == parseInt(this.workNum) && linJiisfirst">提示：如果扫码后无反应，请检查输入框是否获得焦点</view>
						
						
						<u-form-item label="栈板条码" label-width="150rpx" required v-if="emsCodeCount.palletCodeCount">
							<u-input
								 v-model="emsForm.palletCode" 
								 :disabled="disabledemsP"
								 ref="focuspallet1" 
								 :focus="autofocuspallet"
								 placeholder=" " 
								 type="text" 
								 border 
								 @input="circleDecEmsPallet"/>
						</u-form-item>
						
						<u-form-item label="铭牌编码" label-width="150rpx" required v-if="emsCodeCount.nameplatesCodeCount">
							<u-input
								 v-model="emsForm.nameplatesCode" 
								 :disabled="disabledemsMp"
								 ref="focuspallet2" 
								 :focus="autofocuspallet"
								 placeholder=" " 
								 type="text" 
								 border 
								 @input="circleDecEmsMp"/>
						</u-form-item>
						
						<u-form-item label="运维二维码" label-width="150rpx" required v-if="emsCodeCount.operationAndMaintenanceOrCodeCount">
							<u-input
								 v-model="emsForm.operationAndMaintenanceOrCode" 
								 :disabled="disabledemsYW"
								 ref="focusYW2" 
								 :focus="autofocuspallet"
								 placeholder=" " 
								 type="text" 
								 border 
								 @input="circleDecYW"/>
						</u-form-item>
						
						<view style="font-size: 10rpx;color: #666666;" v-if="emsCodeCount.palletCodeCount">提示：如果扫码后无反应，请检查输入框是否获得焦点</view>
						
						<!-- <scroll-view class="input-contain" scroll-y="true">
							<view class="list-item" v-for="(item,index) in deviceCodeList" :key="index">
								<text>{{index+1}}</text>
								<u-input
									v-model="item.deviceCode"
									placeholder="请输入条码" 
									ref="values"
									type="text"
									border
									style="width: 350rpx;"/>
							</view>
						</scroll-view> -->
						
						 <!-- 2024-8-8去掉了 （原因：不需要了） 判断if条件还有emsCodeCount.processOrder == '01'
						     -->
						<u-form-item label="工装设备条码" label-width="180rpx" required v-if="validEmsFacilityBarcode.length">
							<u-input
								 v-model="emsFacilityBarcode"
								 ref="focusemsFacilityBarcode"
								 placeholder=" "
								 type="text"
								 border/>
						</u-form-item>
						
						<u-form :model="form" ref="uForm" style="margin-top: 20rpx;" @submit.native.prevent v-if="deviceCodeList.length || accessoryCodeList.length">
							<u-divider color="#2979ff" style="margin-top: 20rpx;" v-if="emsCodeCount.deviceCodeCount">器件条码</u-divider>
									<u-form-item label="器件条码" label-width="150rpx" required v-if="emsCodeCount.deviceCodeCount">
										<u-input
											 v-model="emsForm.deviceCodes" 
											 :disabled="disabledemsD"
											 ref="devicesCode1" 
											 placeholder=" " 
											 type="text" 
											 border
											 @keypress.native="handleKeyPress"  
											 @input="circleDecEmsDevice"/>
									</u-form-item>
							        <div class="tableHeader" style="margin-top: 20rpx;" v-if="emsCodeCount.deviceCodeCount">
							          <div class="tableHeaderId" style="width: 100rpx;">序号</div>
							          <div class="tableHeaderName" style="width: 400rpx;">物料编码</div>
							          <div class="tableHeaderName" style="width: 400rpx">描述</div>
									  <div class="tableHeaderName" style="width: 400rpx;">器件条码</div>
							        </div>
							        <!-- <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" style="max-height: 500rpx;" v-if="emsCodeCount.deviceCodeCount"> -->
							          <div class="tableContent" v-for="(item,index) in deviceCodeList" :key="index" v-if="emsCodeCount.deviceCodeCount">
							            <div class="tableContentId" style="width: 100rpx;" >{{index+1}}</div>
							            <div class="tableContentName" style="width: 400rpx;">{{item.outid}}</div>
							            <div class="tableContentName" style="width: 400rpx;" @click="showComplete(item)">
											<!-- 固定高度 -->
											<!-- <div class="tabledescript">
												{{item.descript}}
											</div> -->
											<div>
												{{item.descript}}
											</div>
										</div>
										<div class="tableContentName" style="width: 400rpx;" >
											<!-- <u-input input-align="center" 
											:focus="item.focus" 
											disabled
											placeholder="请扫码匹配输入"
											v-model="item.deviceCode" /> -->
											<div style="white-space: normal;word-break: break-word;">
												{{item.deviceCode?item.deviceCode:'请扫码匹配输入'}}
											</div>
										</div>
							          </div>
							        <!-- </scroll-view> -->
									<u-modal v-model="showContentEms" :content="contentEms"></u-modal>
									
							<u-divider color="#2979ff" style="margin-top: 20rpx;" v-if="emsCodeCount.accessoryCodeCount">附件条码</u-divider>
							<div style="display: flex;">
							    <u-form-item :label="workCenter == '总装车间' && lineType == '2' ? '附件包' : '附件条码'" label-width="130rpx" required v-if="boolFJ">
							    	<u-input
							    	style="width: 800rpx;"
							    		 v-model="emsForm.accessoryCodes" 
							    		 :disabled="disabledemsA"
							    		 ref="accessoryCode1" 
							    		 :focus="autofocusAccessory"
							    		 placeholder="请扫码匹配输入" 
							    		 type="text" 
							    		 border 
							    		 @input="circleDecEmsAttach"/>
							    </u-form-item>
							    <u-form-item style="margin-left: 30rpx;" label="重量" label-width="80rpx" required v-if="workCenter !== '总装车间' && emsCodeCount.accessoryCodeCount">
								<u-input
									 v-model="emsForm.weight"	
									 :disabled="disabledemsB"
									 ref="accessoryWeight"
									 placeholder="重量"
									 type="text" 
									 border 
									 @input="circleDecEmsWeight"/>
							</u-form-item>
							</div>
							<div class="tableHeader" style="margin-top: 20rpx;" v-if="boolFJ">
							  <div class="tableHeaderId" style="width: 100rpx;">序号</div>
							  <div class="tableHeaderName" style="width: 400rpx;">物料编码</div>
							  <div class="tableHeaderName" style="width: 400rpx">描述</div>
							  <!-- <div v-if="workCenter == '总装车间'" class="tableHeaderName" style="width: 400rpx">条码包</div> -->
							  <div class="tableHeaderName" style="width: 400rpx;">附件条码</div>	
							</div>
							<!-- <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" style="max-height: 500rpx;" v-if="emsCodeCount.accessoryCodeCount"> -->
							  <div class="tableContent" v-for="(item,index) in accessoryCodeList" :key="index+1" v-if="boolFJ">
							    <div class="tableContentId" style="width: 100rpx;" >{{index+1}}</div>
							    <div class="tableContentName" style="width: 400rpx;">{{item.outid}}</div>
							    <div class="tableContentName" style="width: 400rpx;" @click="showComplete(item)">
									<!-- <div class="tabledescript">
										{{item.descript}}
									</div> -->
									<div>
										{{item.descript}}
									</div>
								</div>
								<!-- <div v-if="workCenter == '总装车间'" class="tableContentName" style="width: 400rpx;">{{item.code}}</div> -->
								<div class="tableContentName" style="width: 400rpx;" >
									<!-- <u-input
									input-align="center"
									:focus="item.focus" 
									disabled
									placeholder=""
									v-model="item.deviceCode"/> -->
									<div style="white-space: normal;word-break: break-word;">
										{{item.deviceCode?item.deviceCode:'请扫码匹配输入'}}
									</div>
								</div>
							  </div>
							<!-- </scroll-view> -->
						</u-form>
							<div>
							<u-form-item label="附件包" label-width="150rpx" required v-if="this.workCenter == '总装车间' && lineType == 1 && this.sonAccessoryCodeList.length">
								<u-input
									 v-model="emsForm.parentCode"
									 :disabled="parentDisabledems"
									 ref="accessoryParentn"
									 placeholder="请扫码匹配输入"
									 type="text" 
									 border
									 @input="inputParent"/>	
							</u-form-item>
							<u-form-item label="附件条码" label-width="150rpx" required v-if="this.workCenter == '总装车间' && lineType == 1 && this.sonAccessoryCodeList.length">
								<u-input
									 v-model="emsForm.sonCode"	
									 :disabled="sonDisabledems"
									 ref="accessorySon"
									 placeholder="请扫码匹配输入"
									 type="text" 
									 border
									 @input="inputSon"/>
							</u-form-item>
							</div>
							<div class="tableHeader" style="margin-top: 20rpx;" v-if="this.workCenter == '总装车间' && lineType == 1 && this.sonAccessoryCodeList.length">
							  <div class="tableHeaderId" style="width: 100rpx;">序号</div>
							  <div class="tableHeaderName" style="width: 400rpx;">附件包</div>
							  <div class="tableHeaderName" style="width: 400rpx;">附件条码</div>
							  <div class="tableHeaderName" style="width: 400rpx;">扫描附件包</div>
							  <div class="tableHeaderName" style="width: 400rpx;">扫描附件条码</div>
							</div>
							<!-- <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" style="max-height: 500rpx;"> -->
							<div class="tableContent" v-for="(item,index) in sonAccessoryCodeList" :key="index+1">
							    <div class="tableContentId" style="width: 100rpx;" >{{index+1}}</div>
							    <div class="tableContentName" style="width: 400rpx;white-space: normal;word-break: break-word;">{{item.descript}}</div>
							    <div class="tableContentName" style="width: 400rpx;white-space: normal;word-break: break-word;">{{item.outid}}</div>
								<div class="tableContentName" style="width: 400rpx;" >
									<div style="white-space: normal;word-break: break-word;">
										{{item.parentCode?item.parentCode:'请扫码匹配输入'}}
									</div>
								</div>
								<div class="tableContentName" style="width: 400rpx;" >
									<div style="white-space: normal;word-break: break-word;">
										{{item.deviceCode?item.deviceCode:'请扫码匹配输入'}}
									</div>
								</div>
							</div>
						<u-button type="success" class="gap" @click="handleBarcodeEms">上传条码</u-button>
						<u-toast ref="uToast" />
					</u-form>
					
				</view>
				<view class="gap1">
					<view>异常报警</view>
					<u-radio-group v-model="value">
						<u-radio 
							@change="radioChange" 
							v-for="(item, index) in machineError" :key="index" 
							:name="item.name"
						>
							{{item.name}}
						</u-radio>
					</u-radio-group>
					<u-form-item label="异常小类:" v-if="errorMins.length" :border-bottom="false" label-width="130">
						<u-radio-group v-model="abnormalNameMin">
							<u-radio 
								@change="nameMinRadioChange" 
								v-for="(item, index) in errorMins" :key="index" 
								:name="item.name"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-input
						v-model="emsContent"
						placeholder="请输入异常描述(最多50个字)" 
						ref="emsContent" 
						type="textarea"
						maxlength="50"
						border
						class="gap"/>
					<u-button
							  style="height:40px;"
							  type="success"
							  class="gap"
							  @click="handleError">
							  异常上传
					</u-button>
				</view>
			</view>
			<!-- 非数控车间扫码 -->
			<view v-else>
				<view class="gap">工件条形码编号扫码输入</view>
				<view>
					<u-form :model="form" style="width: 300px; height: 50rpx;" class="gap">
						<u-input :focus="autofocus" 
								 :disabled="disabled" 
								 v-model="form.value" 
								 ref="inputValues" 
								 placeholder="请使用扫码枪输入内容" @input="strThanSix" type="text" border/>
						<u-toast ref="uToast" />
					</u-form>
				</view>	
				<view class="gap" style="font-size: 10rpx;color: #666666;">提示：如果扫码后无反应，请检查输入框是否获得焦点</view>
				<view class="gap1">
					<view>破损工件条形码编号手动输入</view>
					<u-form :model="form" style="width: 300px; height: 50rpx;" class="gap">
						<u-input :disabled="disabled" v-model="form.handleInput" placeholder="请使用键盘输入内容" ref="values" type="text" border/>
						<u-button :disabled="disabled" type="success" class="gap" @click="handleRecord">上传条码</u-button>
					</u-form>
				</view>	
			
			
				<view class="gap1">
					<view>异常报警</view>
					<u-radio-group v-model="value">
						<u-radio 
							@change="radioChange" 
							v-for="(item, index) in machineError" :key="index" 
							:name="item.name"
						>
							{{item.name}}
						</u-radio>
					</u-radio-group>
					<u-form-item label="异常小类:" v-if="errorMins.length" :border-bottom="false" label-width="130">
						<u-radio-group v-model="abnormalNameMin">
							<u-radio 
								@change="nameMinRadioChange" 
								v-for="(item, index) in errorMins" :key="index" 
								:name="item.name"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-input
						v-model="zPcontent"
						placeholder="请输入异常描述(选填,最多50个字)" 
						ref="values" 
						type="textarea"
						maxlength="50"
						border
						class="gap"/>
					<u-button :disabled="disabled"
							  style="width:300px;height:40px;"
							  type="success"
							  class="gap"
							  @click="handleError">
							  异常上传
					</u-button>
				</view>
			</view>
			<view :class="workCenter == '数控车间' || workCenter == '焊接车间' || workCenter == '喷涂车间'?'gap2': workCenter == 'EMS总装车间'?'gap4':'gap1'">
				<view>员工手机扫码绑定</view>
				<tki-qrcode
					class="gap"
					v-if="ifShow" 
					cid="qrcode1" 
					ref="qrcode" 
					:val="val" 
					:size="size" 
					:unit="unit" 
					:background="background" 
					:foreground="foreground" 
					:pdground="pdground"
					:lv="lv" 
					:onval="onval" 
					:loadMake="loadMake" 
					:usingComponents="true" 
					 />
					 <!-- @result="qrR" -->
			</view>
			<view class="gap1" v-if="workCenter != '数控车间' && workCenter != 'EMS总装车间' && workCenter != '焊接车间' && workCenter != '喷涂车间'">
				<view>设置工序序号</view>
				<u-form :model="changeForm" ref="uForm" label-width="150" style="width: 300px; height: 50rpx;" class="gap">
					<u-form-item label="工序序号">
						<u-input 
								 v-model="selectValue"
								 type="select"
								 @click="show = true"
								 placeholder="请输入工位序号" border/>
					</u-form-item>
					<u-form-item label="工段长工号" prop="jobNumber">
						<u-input
								 v-model="changeForm.jobNumber" 
								 placeholder="请输入工段长工号" type="text" border/>
					</u-form-item>
					<u-form-item label="密码" prop="password">
						<u-input
								 v-model="changeForm.password" 
								 placeholder="请输入密码" type="password" border/>
					</u-form-item>
					<u-button @click="submit" style="width:300px;height:40px;" type="success">提交修改</u-button>
				</u-form>
				<u-action-sheet :list="actionSheetList" v-model="show" @click="actionSheetCallback"></u-action-sheet>
			</view>
		</view>
		<view class="u-flex u-col-top scanListGap">
			<view>
				<view>扫码记录</view>
				<view :class="workCenter == 'EMS总装车间'?'emsScanclass':''" v-for="(item,index) in this.logs">{{item}}</view>
			</view>
		</view>
		<view style="color: red;">
			<view>
				<img src="@/static/tk.png" alt="" />
				<view>扫码如果出现以上弹窗：默认点击取消。</view>
				<view>如果之前按了刷新，F5，可以点击离开</view>
				<view>不清楚怎么操作的，联系研发人员！</view>
			</view>
		</view>
		<u-modal :value="showPT" title="重要注意事项" width='2700' @confirm="showPT = false">
		<div style="font-size: 90px; color: red; height: 600px;margin: 60px 200px 0 200px;">因为断网，请到喷涂自动化系统再扫描一次工单，扫描完成后才能点击“确认”。</div>
		</u-modal>
		<u-modal :value="JGFFshow3" title="注意" content='机柜条码长度小于3' @confirm="JGFFconfirm3"></u-modal>
		<u-modal :value="JGFFshow" title="注意" content='机柜条码存在非法字符' @confirm="JGFFconfirm"></u-modal>
		<u-modal :value="ZBshow" title="注意" content='栈板条码存在非法字符' @confirm="ZBconfirm"></u-modal>
		<u-modal :value="ZBshow3" title="注意" content='栈板条码长度小于3' @confirm="ZBconfirm3"></u-modal>
		<u-modal :value="QJshow" title="注意" content='器件条码存在非法字符' @confirm="QJconfirm"></u-modal>
		<u-modal :value="QJshow3" title="注意" content='器件条码长度小于3' @confirm="QJconfirm3"></u-modal>
		<u-modal :value="FJshow" title="注意" content='附件条码存在非法字符' @confirm="FJconfirm"></u-modal>
		<u-modal :value="YWshow" title="注意" content='运维二维码存在非法字符' @confirm="YWconfirm"></u-modal>
		<u-modal :value="modalshow" title="注意" :content='content' @confirm="JGFFconfirm"></u-modal>
		<u-select :defaultValue="defaultValue" v-model="showMachine" mode="mutil-column-auto" :list="machineList" @confirm="confirm"></u-select>
		<!--  :defaultValue="[{label:'机器人组'},{label:'JH05',name:'JH05'}]" -->
	</view>
</template>
	

<script>
import store from '@/utils/store/index.js'
import { log } from 'util'
import tkiQrcode from '../components/tki-qrcode/tki-qrcode.vue'
import { getUserTechnologyFileRecord,selMaterialCodeLen,getBindingStationUser,machineUnbindList1,sopScan,userScan,emsScan,findsectionNo,findDeviceCodeCount,addAbnormalInfo,getPdf,managerLogin,process,getMachineList,machineScan,machineStationScan,pt_oneNet,machineAbnormalCommit,getBindingUser,getStationBindingUser,packagingComparison,findProcessJobClassCodeEms,ptsCode,findLinJi,saveLinJibinding,findUser,findPlanMachine,machineUnBindList,machineBindList,machineStationAbnormalCommit,getEmsFacilityBarcode } from '../utils/index.js'
	export default {		
		data() {
			return {
				showPT: false,
				boolFJ: false,
				content:'',
				modalshow: false,
				YWshow:false,
				FJshow:false,
				showDialog: false, // 控制是否显示弹出框
				JGFFshow: false,
				JGFFshow3: false,
				ZBshow: false,
				ZBshow3: false,
				QJshow: false,
				QJshow3: false,
				disabledemsMp:false,
				disabledemsYW:false,
				sonDisabledems:false,   // 子附件表单dis
				parentDisabledems: false,// 附件包表单dis
				machineType:'',
				defaultValue:[0,0],    // 打开弹窗默认的机台
				qualityMax:'',     // 机台最大绑定人数
				address:'',
				sectionAbbreviation:'',
				batchDisabled: true,
				logs: [],						//存放扫码记录的数组
				form: {
					value: '',					//扫码输入框信息
					handleInput: '' 			//键盘输入框信息
				},
				changeForm: {
					jobNumber: '',
					sectionNo: '',
					password: ''
				},
				normalrequest: false,
				selectValue: '',
				routeInfo: '',	  				//工段编号+工位编号组合的路由信息
				sectionNum: '',  				//工段编号
				workNum: '',				 	//工位编号
				focus: true,
				resMsg: '',		 				//条形码发送到后台返回的信息
				serviceTime: '',	 			//条形码传到服务器后返回的时间戳
				list: [
					{
						name: '工艺'
					},
					{
						name: '质量'
					},
					{
						name: '检验'
					},
					{	
						name: '缺料'
					}
				],
				machineError: [
					{
						name: '工艺'
					},
					{
						name: '质量'
					},
					{
						name: '计划'
					},
					{
						name: '物流'
					},
					{
						name: '制造'
					},
					{
						name: '设备'
					},
				],
				machineErrorMin: [
					{
						errorMin: [{name:'模具异常'},{name:'图纸错误'},{name:'编程错误'},{name:'流程错误'},{name:'验证问题'},{name:'BOM错误'},{name:'SOP错误'}]
					},
					{	
						errorMin: [{name:'来料不良'},{name:'制程不良'},{name:'问题判定'}]
					},
					{
						errorMin: [{name:'欠料'},{name:'漏排产'},{name:'工单异常'}]
					},
					{
						errorMin: [{name:'配送不及时'},{name:'物料配送错'},{name:'少料'},{name:'多料'}]
					},
					{
						errorMin: [{name:'批量停线'},{name:'红线问题'}]
					},
					{
						errorMin: [{name:'不工作'},{name:'漏油'},{name:'漏电'},{name:'异响'},{name:'报警'},{name:'加工偏差'},{name:'其它'}]
					},
				],
				errorMins: [],
				rules: {
					jobNumber: [
						{ 
							required: true, 
							message: '请输入工段长工号', 
							// 可以单个或者同时写两个触发验证方式 
							trigger: ['change','blur']
						}
					],
					password: [
						{ 
							required: true, 
							message: '请输入密码', 
							// 可以单个或者同时写两个触发验证方式 
							trigger: ['change','blur']
						}
					]
				},
				workNumList: [],
				value: '',						//异常报警选定的选项，默认为'工艺'
				abnormalNameMin:'',
				zPcontent: '',					//装配异常描述，选填
				disabled: true,					//按钮与输入框是否禁用条件
				reminderSwitch: true,				//提示语句的切换
				autofocus: true,
				ifShow: true,
				val: sessionStorage.getItem('routeInfo'), // 要生成的二维码值
				size: 600, // 二维码大小
				unit: 'upx', // 单位
				background: '#b4e9e2', // 背景色
				foreground: '#309286', // 前景色
				pdground: '#32dbc6', // 角标色
				lv: 3, // 二维码容错级别 ， 一般不用设置，默认就行
				onval: true, // val值变化时自动重新生成二维码
				loadMake: true, // 组件加载完成后自动生成二维码
				src: '', // 二维码生成后的图片地址或base64
				show: false,
				actionSheetList: [
					{
						text:"01"
					},
					{
						text:"02"
					},
					{
						text:"03"
					},
					{
						text:"04"
					},
					{
						text:"05"
					},
					{
						text:"06"
					},
					{
						text:"07"
					},
					{
						text:"08"
					},
					{
						text:"09"
					},
					{
						text:"10"
					},
					{
						text:"11"
					},
					{
						text:"12"
					},
					{
						text:"13"
					},
					{
						text:"14"
					},
					{
						text:"15"
					},
					{
						text:"16"
					}
				],
				// 《数控车间部分，start
				machineList: [],
				showMachine: false,
				workCenter: '',
				machineForm: {
					completionQuantity: '',
					deviceBarcode: ''
				},
				// 批量扫码列表
				batchList: [
					{
						deviceBarcode:'',
						completionQuantity:''
					}
				],
				errorForm:{
					deviceBarcode: '',
					value: '',			//数控车间异常报警选定的选项，默认为'工艺'
					content: '',
					abnormalNameMin: ''
				},
				bindingUser: {},
				pForm: {
					planNo: ''
				},
				showCNCbinder: false,
				contentCNCbinder: '',
				disabledMachine: false,
				cncUnDone: false,
				step: -1,
				upperLimit: 0,
				machineBindForm: {
					jobNumber1: '',
					jobNumber2: '',
					jobNumber3: '',
					jobNumber4: '',
					jobNumber5: ''
				},
				numList: [{
						name: '设备条码'
					}, {
						name: '解绑机台'
					}, {
						name: '绑定机台'
					}, {
						name: '上传条码'
					}
				],
				cnclist: [
					{
						name: '扫码输入',
						disabled: false
					},
					{
						name: '手动输入',
						disabled: false
					},
					{
						name: '批量扫码',
						disabled: false
					},
				],
				cncScanType: '扫码输入',
				cncrequest: false,
				findPlanMachineSuccess: false,
				// 数控车间部分,end
				// EMS总装车间，start
				processName: '',
				deviceCodeList: [],			//器件条码列表
				accessoryCodeList: [],		//附件条码列表
				sonAccessoryCodeList: [],		//子附件条码列表
				emsContent: '',					//ems车间异常描述，选填
				isGetCode: false,
				emsCodeCount: {},
				emsForm: {
					deviceBardcode: '',
					palletCode: '',
					deviceCode: ''
				},
				codeEmsList: [],
				ptsCodeList: [],
				disabledems: false,
				disabledemsP: false,
				disabledemsD: false,
				deviceCodeListfocus: false,
				autofocusAccessory: false,
				weightAccessory: false, // 重量
				autofocuspallet: false,
				autofocusdevice: false,
				contentEms: '',
				showContentEms: false,
				workOrderNoType: '',
				technologyNo: '',
				deviceBardcodeList: [],
				validEmsFacilityBarcode: [],			//已维护工装设备条码列表
				emsFacilityBarcode: '',					//ems，扫入工装设备条码
				showdeviceBardcodes: false,
				linJiObj: {},		//临技
				disabledemsLJ: false,
				linJiisfirst: true,
				deviceDarcodeLinJiNew: '',
				// 器件校验
				methodIsGoon: false,
				methodIsGoon1: false,
				methodIsGone: false,
				methodIsGone1: false,
				// 附件校验
				methodIsGoon2: false,
				methodIsGoon3: false,
				methodIsGone2: false,
				methodIsGone3: false,
				disabledemsA:false,
				disabledemsB:false,
				emsrequest: false,
				// EMS总装车间，end
				bool:false,
				typeList:'',
				timer: 0,
				technologyNo:'',
				stationIdentifying:'',
				jobNumber:'',
				staProcessOrder:'',// 钣金工序
				lineType:'',  // 线体类型:  2 装配
				attachmentBags:[], // 附件包列表
				PTbool: false,
			}
		},
		methods: {
			// 切换机台显示的要一样
			workNumClick(){
				console.log(this.machineType);
				const a = this.machineList.findIndex(item => item.label == this.machineType)
				console.log('this.machineList',this.machineList);
				console.log('a',a);
			    const b = this.machineList[a].children.findIndex(item => item.value == this.workNum)
				this.defaultValue = [a,b]
				this.showMachine = true
			},
			// 检查readTag与watchTag来确定用户是否可以开始扫码工作
			//装配当且仅当readTag与watchTag同时为1才可以开始工作
			// 数控当且仅当readTag为1才可以开始工作
			async scanSwitch() {
				if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间'){
					// this.disabled = !Number(sessionStorage.getItem('readTag'))
					// this.reminderSwitch = !Number(sessionStorage.getItem('readTag'))
					console.log('数控、焊接、喷涂通过扫码接口进行判断是否进行文档阅读')
				} else{
					if(this.workCenter == '总装车间') {
					    await this.getProcess()
					    let query = {technologyNo:this.technologyNo,stationIdentifying: this.stationIdentifying}
						console.log(11,query);
					    if(!this.jobNumber){  //查不到工号
					    	sessionStorage.setItem("readTag", 0)
					    	return this.$refs.uToast.show({
					    		title: '该工单工段工序无人绑定 !',
					    		type: 'error',
					    		icon: true
					    	})
					    }
					    query.jobNumber = this.jobNumber
					    const res2 = await getUserTechnologyFileRecord(query)
					    console.log('看文档凭证',res2)
					    if(res2.data.data && res2.data.data.sopFile) {
					    	sessionStorage.setItem("readTag", 1)
					    } else {
					    	sessionStorage.setItem("readTag", 0)
					    }
					    if(Number(sessionStorage.getItem('readTag')) || Number(sessionStorage.getItem('watchTag'))){
					    	// this.disabled = false
					    	this.reminderSwitch = false
					    	this.disabledems = false
					    	this.disabledemsP = false
					    	this.disabledemsD = false
					    	this.disabledemsA = false
					    	this.disabledemsB = false
					    } else {
							this.reminderSwitch = true
							this.disabledems = true
							this.disabledemsP = true
							this.disabledemsD = true
							this.disabledemsA = true
							this.disabledemsB = true
					    }
					}
					// this.disabled = !Number(sessionStorage.getItem('readTag'))  || !Number(sessionStorage.getItem('watchTag'))
					// this.reminderSwitch = !Number(sessionStorage.getItem('readTag')) || !Number(sessionStorage.getItem('watchTag'))
					console.log('非数控',this.disabledems)
				}
				// 当员工看完视频与文档以后，回到主页面则直接将焦点聚集在扫码框上
				if(this.disabled == true) {
					console.log("YES")
				} else {
					setTimeout(() => this.getFocus(), 100)
				}
			},
			// e代表选择异常警告的种类，为字符串，例如工艺，质量，检验与缺料中的一种
			radioChange(e) {
				this.value = e
				this.abnormalNameMin = ''
				this.machineError.forEach((item,index)=>{
					if(item.name == e){ this.errorMins = this.machineErrorMin[index].errorMin }
				})
			},
			// e代表选择异常警告的种类，为字符串，例如工艺，质量，计划与物流中的一种
			machineRadioChange(e){
				this.errorForm.value = e
				this.errorForm.abnormalNameMin = ''
				this.machineError.forEach((item,index)=>{
					if(item.name == e){ this.errorMins = this.machineErrorMin[index].errorMin }
				})
			},
			nameMinRadioChange(e){
				this.errorForm.abnormalNameMin = e
			},
			// 将选择的异常警告经过处理发送到后台
			async handleError() {
				const query = {}
				query.sopBarcode = sessionStorage.getItem('routeInfo')
				if(this.value == '') return this.$refs.uToast.show({
						title: '请先选择异常类型',
						type: 'error',
						icon: true
					})
				if(this.abnormalNameMin == '') return this.$refs.uToast.show({
						title: '请先选择异常小类',
						type: 'error',
						icon: true
					})
				if(this.emsContent == '') return this.$refs.uToast.show({
					title: '异常描述不能为空',
					type: 'error',
					icon: true
				})
				query.abnormalType = this.value == '工艺' ? '0' : 
									 this.value == '质量' ? '1' :
									 this.value == '计划' ? '8' :
									 this.value == '物流' ? '9' :
									 this.value == '制造' ? '7' :
									 this.value == '设备' ? '4' :'1'
				if(this.zPcontent) { query.content = this.zPcontent}
				if(this.emsContent) { query.content = this.emsContent}
				if(this.abnormalNameMin) { query.abnormalNameMin = this.abnormalNameMin}
				const { data } = await addAbnormalInfo(query)
				const errInfo = data.msg										//后台返回的错误信息
				if(data.code == '1') {
					this.value = ''
					this.zPcontent = ''
					this.emsContent = ''
					this.abnormalNameMin = ''
					this.$refs.uToast.show({
						title: errInfo,
						type: 'success',
						icon: true
					})
				} else {
					this.$refs.uToast.show({
						title: errInfo,
						type: 'error',
						icon: true
					})
				}
			},
			// 扫码信息传给后台系统，记得加入异步
			async scanRecord() {
				const query = {}
				if(this.judgeSectionNum()){
					query.barCode = sessionStorage.getItem('routeInfo'),
					query.stationIdentifying = this.form.value
				} else {
					query.sopBarcode = sessionStorage.getItem('routeInfo')
					query.deviceBardcode = this.form.value
				}
				const { data } = this.judgeSectionNum()?await userScan(query):await sopScan(query)
				this.resMsg = data.msg
				this.serviceTime = data.data == null ? '' : data.data
				if(data.code == '1') {
					this.$refs.uToast.show({
						title: this.resMsg,
						type: 'success',
						icon: true
					})
					this.recordData(this.form.value)
				} else {
					this.$refs.uToast.show({
						title: this.resMsg,
						type: 'error',
						icon: true
					})
				}
				this.disabled = false
				this.form.value = ''								//无论扫码是否成功，均对输入框进行清空
				setTimeout(() => this.getFocus(), 100)
			},
			// 光标聚焦到扫码输入框中
			getFocus() {
				// 这里的输入框焦点将在自动聚焦
				this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
			},
			// 手动上传条形码按钮绑定函数
			async handleRecord() {
				if(this.normalrequest) return this.$refs.uToast.show({
					title: '请求过于频繁！',
					type: 'error',
					icon: true
				})
				this.normalrequest = true
				let _this = this
				setTimeout( function() {
					_this.normalrequest = false
				}, 1000)
				const query = {}
				if(this.judgeSectionNum()){
					query.barCode = sessionStorage.getItem('routeInfo'),
					query.stationIdentifying = this.form.handleInput
				} else {
					query.sopBarcode = sessionStorage.getItem('routeInfo')
					query.deviceBardcode = this.form.handleInput
				}
				if(this.form.handleInput.length < 6 && !this.judgeSectionNum()) {
					this.$refs.uToast.show({
						title: '条形码编号不得小于六位',
						type: 'error',
						icon: true
					})
				} else {
					console.log('query',query);
					const {data} = this.judgeSectionNum()?await userScan(query):await sopScan(query)
					this.resMsg = data.msg
					this.serviceTime = data.data == null ? '' : data.data
					if(data.code == '1') {
						this.$refs.uToast.show({
							title: this.resMsg,
							type: 'success',
							icon: true
						})
						this.recordData(this.form.handleInput)			//若后台认为扫码成功，则记录信息在页面
					} else {
						this.$refs.uToast.show({
							title: this.resMsg,
							type: 'error',
							icon: true
						})
					}
					this.form.handleInput = ''							//手动上传条码无论成功与否，均清空
				}
			},
			// 判断扫码输入框的字符串大于6时则调用该函数
			strThanSix() {
				if(this.form.value.length < 6 && !this.judgeSectionNum()) {
					console.log('不发送')
				} else {
					this.circleDec()
				}
			},
			// 将路由或者sessionStorage获取来的信息切割开来分别赋值给sectionNum与workNum
			handleString(value,type) {
				// 该判断需要测试
				// if(this.workNum && this.sectionNum && !type) return
				
				this.sectionNum = value.substring(0,6)
				this.workNum = value.substring(6)
				this.val = this.sectionNum + this.workNum
				this.findsectionNo(this.sectionNum)
			},
			// 获取线体类型
			async findsectionNo(val){
				const { data } = await findsectionNo({sectionNo:val})
				console.log('data111',data);
				if (!data.data) {
					this.workCenter = ''
					this.sectionAbbreviation = ''
					this.address = ''
					this.sectionNum = ''
					return
				}
				this.workCenter = data.data.workCenter
				sessionStorage.setItem('workCenter',this.workCenter)
				this.lineType = data.data.lineType  // 线体
				console.log('线体',this.lineType);
				if(this.workCenter == '喷涂车间'){
					this.cnclist = [
						{
							name: '扫码输入',
							disabled: false
						},
						{
							name: '手动输入',
							disabled: false
						}
					]
				}else if(this.workCenter !== '喷涂车间'){
					this.cnclist = [
						{
							name: '扫码输入',
							disabled: false
						},
						{
							name: '手动输入',
							disabled: false
						},
						{
							name: '批量扫码',
							disabled: false
						},
					]
				}
				sessionStorage.setItem("workCenter", this.workCenter)
				this.scanSwitch()					//检查是否查看了PDF文档与视频，若没有查看完毕，则禁用按钮与输入框
				if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间' ){
					this.address = data.data.address
					this.sectionAbbreviation = data.data.sectionAbbreviation
					console.log('this.sectionNum',this.sectionNum)
					this.getMachineList()  // 查所有机台
					this.val = this.workNum
					if(!this.bool){
					   this.getBindingUser() // 用机台查
					}
					return
				} else if(this.workCenter == 'EMS总装车间' || this.workCenter == '总装车间') {
					if(this.isGetCode) return console.log('刷新页面重新获取栈板条码、器件条码、附件条码数量')
					this.findDeviceCodeCount(this.sectionNum,this.workNum)
				}
				// console.log(12312312);
				// console.log('lineType',data)
				this.sectionNoType = data.data.lineType
				this.getProcess()
			},
			// 获取栈板条码、器件条码数量
			async findDeviceCodeCount(val,val1){
				this.deviceCodeList = []
				this.accessoryCodeList = []
				await this.getProcess()
				// console.log('工序1',this.staProcessOrder);
				if(this.workCenter == '总装车间') val1 = this.staProcessOrder
				const { data } = await findDeviceCodeCount({sectionNo:val,processOrder: val1})
				// for(let i = 1;i <= data.data.deviceCodeCount;i++){
				// 	this.deviceCodeList.push({deviceCode: ''})
				// }
				// if(data.data.accessoryCodeCount){
				// 	for(let i = 1;i <= data.data.accessoryCodeCount;i++){
				// 		this.accessoryCodeList.push({ deviceCode: '' })
				// 	}
				// }
				console.log('栈板条码',data.data);
				if(!data.data) return  this.$refs.uToast.show({
				        			title: data.msg,
				        			type: 'error',
				        			icon: true
				        	})
				this.emsCodeCount = data.data	
				this.findProcessJobClassCodeEms(data.data)
				this.ptsCode(data.data.workOrderNo,data.data.orderType)
				this.findLinJi(data.data.workOrderNo,data.data.orderType)
				this.getEmsFacilityBarcode(data.data)
				this.workOrderNoType = data.data.orderType + '-' + data.data.workOrderNo
				this.technologyNo = data.data.technologyNo
				this.isGetCode = true
                
			},
			// 获取器件、附件规格
			async findProcessJobClassCodeEms(val){
				const { data } = await findProcessJobClassCodeEms({produceNo:val.technologyNo,processOrder:val.processOrder,isEnd:1,page:1,limit: 100000})
				if(val.deviceCodeCount) {
					this.deviceCodeList = data.data.list.filter(item => item.type == '器件')
					let arrjoin = []
					console.log('deviceCodeList',this.deviceCodeList)
					this.deviceCodeList.forEach((item,index) =>{
						item.disabled = false
						item.focus = false
						if(parseInt(item.compositionAmount)>1 && !item.isadd){
							item.isadd = true
							for(let i = 1;i<=parseInt(item.compositionAmount)-1;i++){
								let obj = {}
								obj.idx = index+arrjoin.length
								obj.obj1 = Object.assign({},item)
								arrjoin.push(obj)
								// let obj1 = Object.assign({},item)
								// this.deviceCodeList.splice(index+i,0,obj1)
							}
						}
					})
					arrjoin.forEach((item,index) =>{
						this.deviceCodeList.splice(item.idx,0,item.obj1)
					})
				}
				console.log('val',this.lineType);
				if(val.accessoryCodeCount) {
					if(this.workCenter == '总装车间' && this.lineType == 1) {
						this.sonAccessoryCodeList = data.data.list.filter(item => item.type == '附件')
					} else {
						this.accessoryCodeList = data.data.list.filter(item => item.type == '附件')
					}
					// 判断附件列表是否显示
					if(this.workCenter == '总装车间' && this.lineType == 1){	
					    this.boolFJ = false
					} else if(this.emsCodeCount.accessoryCodeCount && this.accessoryCodeList.length){
						this.boolFJ = true
					} else {
						this.boolFJ = false
					}
					// 附件不需要根据compositionAmount生成多个物料条码
					// let arrjoin = []
					// this.accessoryCodeList.forEach((item,index) =>{
					// 	item.disabled = false
					// 	item.focus = false
					// 	if(parseInt(item.compositionAmount)>1 && !item.isadd){
					// 		item.isadd = true
					// 		for(let i = 1;i<=parseInt(item.compositionAmount)-1;i++){
					// 			let obj = {}
					// 			obj.idx = index+arrjoin.length
					// 			obj.obj1 = Object.assign({},item)
					// 			arrjoin.push(obj)
					// 		}
					// 	}
					// })
					// arrjoin.forEach((item,index) =>{
					// 	this.accessoryCodeList.splice(item.idx,0,item.obj1)
					// })
				}
				this.codeEmsList = JSON.parse(JSON.stringify(data.data.list))
				// if(item.outid.substring(0,2) == '03'){ item.outid = item.outid.substring(2,item.outid.length)
				this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
			},
			async ptsCode(val,val1){
				const { data } = await ptsCode({orderNumber:val,orderType: val1})
				if(!data.data){
					console.log('ptscode为空')
					this.ptsCodeList={}
					return
				}
				this.ptsCodeList = JSON.parse(data.data).data
				console.log('ptsCode',this.ptsCodeList);
				if(JSON.parse(data.data).data.sn.length){
					let midArr = JSON.parse(JSON.stringify(JSON.parse(data.data).data.sn))
					if(this.workCenter == '总装车间'){
					    this.deviceBardcodeList = midArr
					} else {
					    midArr.forEach((item,index) =>{	 
					    	if(item.sn.includes('06S')){
					    		item.sn = item.sn.match(/06S(\S*)1P/)[1]
				        		}
				        	})
							this.deviceBardcodeList = midArr
				        }
					}
				console.log(JSON.parse(data.data))
				if(this.ptsCodeList.attachmentBag.length){
				  this.attachmentBags = this.ptsCodeList.attachmentBag.map(obj => {
				    // Object.values(obj) 会返回一个数组，包含obj中所有值的数组  
				    // 因为我们知道每个对象只有一个key，所以我们直接取这个数组的第一个元素  
				    return Object.values(obj)[0];  
				  });  
				}
			},
			// 数控车间部分 Begin 所有机台
			async getMachineList(){
				let query = {}
				const {data} = await getMachineList(query)
				let resMsg = data.msg
				console.log(data)
				if(data.code == '1') {
					let datas = JSON.parse(JSON.stringify(data.data))
					let List = []
					datas.forEach(item=>{
						for(var key in item) {
							let obj = {}
							obj.label = key
							List.push(obj)
						}
					})
					datas.forEach((item,index)=>{
						let key = List[index].label
						let mArr = []
						item[key].forEach(items=>{
							let obj1 = {}
							obj1.label = items.machineId
							obj1.value = items.machineId
							mArr.push(obj1)
						})
						List[index].children = mArr
					})
					this.machineList = List
				} else {
					this.$refs.uToast.show({
						title: resMsg,
						type: 'error',
						icon: true
					})
				}
			},
			confirm(e){
				this.workNum = e[1].label
				this.val = e[1].label
				console.log('e',e);
				let routeInfo = this.sectionNum + this.workNum
				sessionStorage.setItem("routeInfo",routeInfo)
				if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间'){
					this.getBindingUser('stepzero')
				} else { this.getBindingUser() }
				let that = this
				setTimeout( function() {
					that.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
				}, 300)
			},
			// 点击批量上传
			async batchBinder(){
				 for (var i = 0; i < this.batchList.length; i++) {
				    for (var j = i + 1; j < this.batchList.length; j++) {
				      if (this.batchList[i].deviceBarcode === this.batchList[j].deviceBarcode) {
				        return  this.$refs.uToast.show({
				        			title: '设备条码不能重复！',
				        			type: 'error',
				        			icon: true
				        	})
						return
				      }
				    }
				  }
				for(let item of this.batchList) {
					if(!item.deviceBarcode){
				        this.$refs.uToast.show({
				        			title: '设备条码不能为空！',
				        			type: 'error',
				        			icon: true
				        	})
						return
					}
					if(!item.completionQuantity){
					    this.$refs.uToast.show({
					    			title: '数量不能为空！',
					    			type: 'error',
					    			icon: true
					    	})
						return
					}
				}
				
					for(let item of this.batchList) {
						if(item.upperLimit == 1){
							if(!item.jobNumber1) return this.$refs.uToast.show({
									title: '员工工号不能为空！',
									type: 'error',
									icon: true
							})
						} else if(item.upperLimit == 2){
							if(!item.jobNumber1 && !item.jobNumber2) return this.$refs.uToast.show({
									title: '员工工号至少输入一个！',
									type: 'error',
									icon: true
							})
							
							if(item.jobNumber1 == item.jobNumber2) return this.$refs.uToast.show({
									title: '员工工号不能相同！5',
									type: 'error',
									icon: true
							})
						} else if(item.upperLimit == 3){
							if(!item.jobNumber1 && !item.jobNumber2 && !item.jobNumber3) return this.$refs.uToast.show({
									title: '员工工号至少输入一个！',
									type: 'error',
									icon: true
							})
							let bindNum = 0
							if(item.jobNumber1){ bindNum++ }
							if(item.jobNumber2){ bindNum++}
							if(item.jobNumber3){ bindNum++}
							if(bindNum >= 2){
								if(item.jobNumber1 == item.jobNumber2 || item.jobNumber1 == item.jobNumber3 || item.jobNumber2 == item.jobNumber3){
									console.log(item.jobNumber1 == item.jobNumber2);
									console.log(item.jobNumber1 == item.jobNumber3);
									console.log(item.jobNumber2 == item.jobNumber3);
									console.log(item.jobNumber2 == item.jobNumber2 == item.jobNumber3);
									return this.$refs.uToast.show({
											title: '员工工号不能相同！',
											type: 'error',
											icon: true
									})
								}
							}
							
						}
						let query = {
							machineId: this.workNum
						}
						// if(this.workCenter == '喷涂车间'){ query.isSpray = true }
						// const {data} = this.workCenter == '喷涂车间'?await getStationBindingUser(query):await getBindingUser(query)
						const {data} = await getBindingUser(query)
						const bindingUser = data.data
						this.qualityMax = data.data.qualityMax
						if(name == 'stepzero' && this.findPlanMachineSuccess) { this.backStepzero() }
						// 拿到当前机台绑定的员工信息（每个循环都可能不一样）
						let unBindList = []
						if(bindingUser.jobNumber && item.jobNumber1 != bindingUser.jobNumber && item.jobNumber2 != bindingUser.jobNumber && item.jobNumber3 != bindingUser.jobNumber){
							unBindList.push(bindingUser.jobNumber)
						}
						if(bindingUser.jobNumber2 && item.jobNumber1 != bindingUser.jobNumber2 && item.jobNumber2 != bindingUser.jobNumber2 && item.jobNumber3 != bindingUser.jobNumber2){
							unBindList.push(bindingUser.jobNumber2)
						}
						if(bindingUser.jobNumber3 && item.jobNumber1 != bindingUser.jobNumber3 && item.jobNumber2 != bindingUser.jobNumber3 && item.jobNumber3 != bindingUser.jobNumber3){
							unBindList.push(bindingUser.jobNumber3)
						}
						if(bindingUser.jobNumber4 && item.jobNumber1 != bindingUser.jobNumber4 && item.jobNumber2 != bindingUser.jobNumber4 && item.jobNumber4 != bindingUser.jobNumber4){
							unBindList.push(bindingUser.jobNumber4)
						}
						if(bindingUser.jobNumber5 && item.jobNumber1 != bindingUser.jobNumber5 && item.jobNumber2 != bindingUser.jobNumber5 && item.jobNumber5 != bindingUser.jobNumber5){
							unBindList.push(bindingUser.jobNumber5)
						}
						console.log('解绑',unBindList);
						console.log(item);
						if(unBindList.length){
					        let { data } = await machineUnbindList1({machineId: this.workNum,jobNumberList: unBindList.join(',')})
						    console.log('解绑',data);
					        if(data.code == '1') {
					        	// this.getBindingUser() // 获取机台绑定的工号
					        	await this.batchBindList(item) // 批量重新在绑定
					        } else {
					        	this.$refs.uToast.show({
					        		title: data.msg,
					        		type: 'error',
					        		icon: true
					        	})
					        }
						} else {
							await this.batchBindList(item)
						}
						await this.batchBarcode(item)
					}
				// } else {
					// this.step = 1
					// this.machineBindList()
				// }
			},
			// 提交
		 async	batchBarcode(item){
				this.showCNCbinder = false
				let query = {
					deviceBarcode: item.deviceBarcode,
					completionQuantity: item.completionQuantity,
					machineId: item.machineId,
				}
				console.log('machineForm',query);
				query.machineId = this.workNum
				// if(this.workCenter == '喷涂车间'){ query.isSpray = true }
				console.log('query',query);
				const {data} = this.workCenter == '喷涂车间'? await machineStationScan(query):await machineScan(query)
				console.log(data);
				this.findPlanMachineSuccess = false
				const errInfo = data.msg
				this.serviceTime = data.data == null ? '' :this.workCenter == '喷涂车间'?data.data:data.data.data
				sessionStorage.setItem("deviceBarcode",item.deviceBarcode)
				if(data.code == '1') {
					this.$refs.uToast.show({
						title: errInfo,
						type: 'success',
						icon: true
					})
					// item.deviceBarcode = ''
					item.completionQuantity = ''
					item.machineId = ''
					item.jobNumber1 = ''
					item.jobNumber2 = ''
					item.jobNumber3 = ''
					if(this.workCenter != '喷涂车间' && data.data.msg && data.data.msg != null){
						this.$refs.uToast.show({
							title: data.data.msg,
							type: 'error',
							icon: true,
							duration: 3000
						})
					}
					this.recordData(item.deviceBarcode)
				} else {
					this.$refs.uToast.show({
						title: errInfo,
						type: 'error',
						icon: true,
						duration: 3000
					})
				}
				this.batchList = this.batchList.filter(item => {
					if(item.completionQuantity){
						return item
					}
				})
				if(this.batchList.length === 0){
					this.batchList = [{
						deviceBarcode: '',
						completionQuantity: ''
					}]
				}
			},
			// 批量绑定员工
		 async	batchBindList(item){
				let jobNumberList = []
				if(item.jobNumber1 && item.jobNumber1 != this.bindingUser.jobNumber && item.jobNumber1 != this.bindingUser.jobNumber2 && item.jobNumber1 != this.bindingUser.jobNumber3){
					jobNumberList.push(item.jobNumber1)
				}
				if(item.jobNumber2 && item.jobNumber2 != this.bindingUser.jobNumber && item.jobNumber2 != this.bindingUser.jobNumber2 && item.jobNumber2 != this.bindingUser.jobNumber3){
					jobNumberList.push(item.jobNumber2)
				}
				if(item.jobNumber3 && item.jobNumber3 != this.bindingUser.jobNumber && item.jobNumber3 != this.bindingUser.jobNumber2 && item.jobNumber3 != this.bindingUser.jobNumber3){
					jobNumberList.push(item.jobNumber3)
				}
				console.log('绑定',jobNumberList);
				if(!jobNumberList.length){
					this.cncUnDone = false
					this.step = 2
					let that = this
					setTimeout( function() {
						that.$refs.completionQuantity.$el.getElementsByTagName("input")[0].focus()
					}, 300)
					return
				}
				let { data } = await machineBindList({machineId: this.workNum,jobNumberList: jobNumberList.join(',')})
				console.log('绑定',data);
				if(data.code == '1') {
					this.cncUnDone = false
					this.getBindingUser()
				} else {
					this.getBindingUser()
					return	this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			async getcncBinder(){
				if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间'){
					this.handleBarcode()
					return
				}
				if(!this.bindingUser) return this.$refs.uToast.show({
					title: '该机台未绑定员工',
					type: 'error',
					icon: true,
					duration: 3000
				})
				let jobNumberArr = []
				if(this.workCenter == '喷涂车间'){
					if(this.bindingUser.user1){ jobNumberArr.push(this.bindingUser.user1)}
					if(this.bindingUser.user2){ jobNumberArr.push(this.bindingUser.user2)}
					if(this.bindingUser.user3){ jobNumberArr.push(this.bindingUser.user3)}
					if(this.bindingUser.user4){ jobNumberArr.push(this.bindingUser.user4)}
					if(this.bindingUser.user5){ jobNumberArr.push(this.bindingUser.user5)}
				} else {
					if(this.bindingUser.jobNumber){ jobNumberArr.push(this.bindingUser.jobNumber)}
					if(this.bindingUser.jobNumber2){ jobNumberArr.push(this.bindingUser.jobNumber2)}
					if(this.bindingUser.jobNumber3){ jobNumberArr.push(this.bindingUser.jobNumber3)}
					if(this.bindingUser.jobNumber4){ jobNumberArr.push(this.bindingUser.jobNumber4)}
					if(this.bindingUser.jobNumber5){ jobNumberArr.push(this.bindingUser.jobNumber5)}
				}
				let {data} = await findUser({jobNumber: jobNumberArr.join(',')})
				console.log(data)
				if(data.code == '1') {
					this.contentCNCbinder = '绑定该机台的员工：' + data.data
					this.showCNCbinder = true
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true,
						duration: 3000
					})
				}
			},
			
			async PTshow(){
				let query = Object.assign({},this.machineForm)
				query.deviceBarcode = sessionStorage.getItem("deviceBarcode")
				if(this.workCenter == '喷涂车间'){ query.sectionNo = this.sectionNum }
				const res = await pt_oneNet({sectionNo:query.sectionNo,deviceBarcode:query.deviceBarcode})
				if(res.data.code != 1){
					uni.showModal({
						title: '提示',
						content: '调用喷涂自动化系统失败是否重试',
						success: (res) => {
					        if (res.cancel) {
							  this.step = 2
					          // this.$refs.uToast.show({
					          // 	title: '请到喷涂自动化系统扫码！',
					          // 	type: 'error',
					          // 	icon: true
					          // })
							  this.showPT = true
					        } else {
					           this.PTshow()
							}
					      }
					});
					return
				} else {
					this.$refs.uToast.show({
						title: res.data.msg,
						type: 'success',
						icon: true
					})
					let code
					const msg = res.data.msg
					res.data.code == 1 ? code = '成功' : code = '失败'
					this.recordData(this.machineForm.deviceBarcode,code,msg)
				    this.machineForm.deviceBarcode = ''
				}
			},
			// （数焊喷）点击上传条码
			async handleBarcode(){
				if(this.cncrequest) return this.$refs.uToast.show({
					title: '请求过于频繁！',
					type: 'error',
					icon: true
				})	
				if(!this.machineForm.completionQuantity) return this.$refs.uToast.show({ 
					title: '零件数量不能为空！',
					type: 'error',
					icon: true
				})
				this.cncrequest = true
				let _this = this
				setTimeout( function() {
					_this.cncrequest = false
				}, 1000)	
				this.showCNCbinder = false
				let query = Object.assign({},this.machineForm)
				console.log('machineForm',this.machineForm);
				console.log('this.sectionNo',this.sectionNo);
				query.machineId = this.workNum
				if(this.workCenter == '喷涂车间'){ query.sectionNo = this.sectionNum } // ？拿不到
				console.log('query1',query);
				const {data} = this.workCenter == '喷涂车间'? await machineStationScan(query):await machineScan(query)
				console.log('data1',this.bindingUser.machineName,data);
				this.findPlanMachineSuccess = false
				const errInfo = data.msg
				const formattedDateTime = this.formatTimestamp(data.time, 'YYYY-MM-DD HH:mm:ss');
				console.log('时间',formattedDateTime);
				if( data.data == null && this.workCenter == '喷涂车间'){
					this.serviceTime = formattedDateTime
				} else if(data.data && data.data.data) {
					this.serviceTime = data.data.data
				}
				// this.serviceTime = data.data == null && this.workCenter == '喷涂车间' ? formattedDateTime : data.data.data
				console.log(this.machineForm.deviceBarcode);
				sessionStorage.setItem("deviceBarcode",this.machineForm.deviceBarcode)
				if(data.code == '1') {
					if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间'){ this.step = 3 }
					console.log(this.bindingUser.machineName)
					let res = ''
					if(this.bindingUser.machineName == '上挂' && this.bindingUser.machineType == '喷涂二线') {
						console.log('喷涂二线 + 上挂');
						res = await pt_oneNet({sectionNo:query.sectionNo,deviceBarcode:query.deviceBarcode})
						console.log(res);
						if(res.data.code != 1){
							uni.showModal({
								title: '提示',
								content: '调用喷涂自动化系统失败是否重试',
								success: (res) => {
                                    if (res.cancel) {
									  this.step = 2
                                      // this.$refs.uToast.show({
                                      // 	title: '请到喷涂自动化系统扫码！',
                                      // 	type: 'error',
                                      // 	icon: true
                                      // })
									  this.showPT = true
                                    } else {
	                                   this.PTshow()
									}
                                  }
							});
							console.log('上挂中断');		
						}
						let code
						const msg = res.data.msg
						res.data.code == 1 ? code = '成功' : code = '失败'
						this.recordData(this.machineForm.deviceBarcode,code,msg)
						return
					}
					console.log('走了');
					this.$refs.uToast.show({
						title: errInfo,
						type: 'success',
						icon: true
					})
					if(data.data && data.data.msg && data.data.msg != null){
						this.$refs.uToast.show({
							title: data.data.msg,
							type: 'error',
							icon: true,
							duration: 3000
						})
					}
					this.recordData(this.machineForm.deviceBarcode)	
				} else {
					console.log('错误');
					this.$refs.uToast.show({
						title: errInfo,
						type: 'error',
						icon: true,
						duration: 3000
					})
					// if(this.workCenter != '喷涂车间'){ this.step = 2 }
				}
			},
			// 时间搓转换
			formatTimestamp(timestamp, format) {
			    const date = new Date(timestamp); // 将时间戳转换为 Date 对象
			
			    // 定义日期时间格式化函数
			    const formatDate = (value) => {
			        return value < 10 ? '0' + value : value; // 如果值小于 10，在前面补零
			    };
			
			    // 根据传入的格式，返回对应的日期时间字符串
			    const formattedDate = format
			        .replace('YYYY', date.getFullYear())
			        .replace('MM', formatDate(date.getMonth() + 1))
			        .replace('DD', formatDate(date.getDate()))
			        .replace('HH', formatDate(date.getHours()))
			        .replace('mm', formatDate(date.getMinutes()))
			        .replace('ss', formatDate(date.getSeconds()));
			
			    return formattedDate;
			},
			// 刷新绑定机台员工信息
			updateBindingUser(){
				this.getBindingUser()
			},
			// 数控车间获取绑定该机台的所有工号
			async getBindingUser(name){
				let query = {
					machineId: this.workNum
				}
				// if(this.workCenter == '喷涂车间'){ query.isSpray = true }
				// const {data} = this.workCenter == '喷涂车间'?await getStationBindingUser(query):await getBindingUser(query)
				const {data} = await getBindingUser(query)
				// const {data} = await getBindingUser(query)
				console.log('data',data);
				// console.log(data.data.qualityMax);
				this.sectionNum = data.data.sectionNo  // 工段编号
				this.qualityMax = data.data.qualityMax
				this.bindingUser = data.data
				this.machineType = data.data.machineType
				const result = this.$route.query.value.substring(0, 6);
				if(result !== this.sectionNum) {
					this.$refs.uToast.show({
					 	title: '注意：机台工段与你输入的工段不一致',
					 	type: 'warning',
					 	icon: true
					 })
				}
				this.findsectionNo(this.sectionNum)
				if(this.machineForm.deviceBarcode){
				   this.findPlanMachine()
				}
				// this.address = res.data.data.address
				// this.sectionAbbreviation = res.data.data.sectionAbbreviation
				// this.workCenter = data.data.workCenter
				this.bool = true
				if(name == 'stepzero' && this.findPlanMachineSuccess) { 
					console.log('name');
					this.backStepzero() }
			},
			// 数控车间异常上传
			async handleError1(){
				let query = {
					planNo: this.errorForm.deviceBarcode,
					content: this.errorForm.content,
					machineId: this.workNum
				}
				if(this.errorForm.value == '') return this.$refs.uToast.show({
					title: '请先选择异常类型',
					type: 'error',
					icon: true
				})
				if(query.planNo == '') return this.$refs.uToast.show({
					title: '条码不能为空',
					type: 'error',
					icon: true
				})
				if(query.content == '') return this.$refs.uToast.show({
					title: '异常描述不能为空',
					type: 'error',
					icon: true
				})
				query.abnormalType = this.errorForm.value == '工艺' ? '0' :
									 this.errorForm.value == '质量' ? '1' :
									 this.errorForm.value == '计划' ? '8' :
									 this.errorForm.value == '物流' ? '9' :
									 this.errorForm.value == '制造' ? '7' :
									 this.errorForm.value == '设备' ? '4' :'1'
				if(this.errorForm.abnormalNameMin == '') return this.$refs.uToast.show({
					title: '请先选择异常小类',
					type: 'error',
					icon: true
				})
				query.abnormalNameMin = this.errorForm.abnormalNameMin
				// if(this.workCenter == '喷涂车间'){ query.isSpray = true }
				// const {data} = this.workCenter == '喷涂车间'?await machineStationAbnormalCommit(query):await machineAbnormalCommit(query)
				const {data} = await machineAbnormalCommit(query)
				const errInfo = data.msg
				if(data.code == '1') {
					this.errorForm.value = ''
					this.$refs.uToast.show({
						title: errInfo,
						type: 'success',
						icon: true
					})
				} else {
					this.$refs.uToast.show({
						title: errInfo,
						type: 'error',
						icon: true
					})
				}
			},
			// 添加列表
			addBatch(){
				this.batchList.push({deviceBarcode:'',completionQuantity:''})
			},
			// 删除列表
			delBatch(){
				if(this.batchList.length === 1) return
				this.batchList.pop()
				const bool = this.batchList.every(item => item.deviceBarcode)
					if(bool){
						this.batchDisabled = false
					}
			},
			// 批量生产失去焦点
			batchInput(value,index){
				if(this.workCenter != '数控车间' && this.workCenter != '焊接车间' && this.workCenter != '喷涂车间') return
				this.cncUnDone = false
				this.findPlanMachineSuccess = false
				if(!value) {
					this.$refs.uToast.show({
							title: '流转条码不能为空！',
							type: 'error',
							icon: true
					})
					this.batchDisabled = true
					return
				}
				const v1 = value;
				let _this = this
				setTimeout( function() {
					// const v2 = _this.machineForm.deviceBarcode
					if(value){
						_this.disabledMachine = true
						// _this.cncUnDone = true
						_this.batchMachine(value,index)
					}
				}, 300)
			},
			// 验证设备条码
			async batchMachine(value,index){
				this.upperLimit = 0
				let { data } = await findPlanMachine({deviceBarcode: value})
				console.log(data);
				this.disabledMachine = false
				if(data.code == '1') {
					this.findPlanMachineSuccess = true
					if(!data.data.length && this.workCenter !== '喷涂车间'){
						this.$refs.uToast.show({
							title: '流转条码获取工单绑定人数为空！请在后台的工单查询修改删除界面查询这个工单是否绑定该机台。',
							type: 'error',
							icon: true
						})
						this.batchDisabled = true
						let that = this
						setTimeout( function() {
							that.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
						}, 300)
						return
					}
					this.batchDisabled = false
					this.batchList[index].upperLimit = data.data[0].upperLimit
					this.batchStepzero(value,index)
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
					this.batchDisabled = true
				}
			},
			batchStepzero(value,index){
				let bindNum = 0
				if(this.bindingUser.jobNumber){ bindNum++ }
				if(this.bindingUser.jobNumber2){ bindNum++}
				if(this.bindingUser.jobNumber3){ bindNum++}
				if(this.bindingUser.jobNumber4){ bindNum++}
				if(this.bindingUser.jobNumber5){ bindNum++}
				if(bindNum <= this.batchList[index].upperLimit){
					this.batchList[index] = {
						...this.batchList[index],
						jobNumber1: this.bindingUser.jobNumber?this.bindingUser.jobNumber:'',
						jobNumber2: this.bindingUser.jobNumber2?this.bindingUser.jobNumber2:'',
						jobNumber3: this.bindingUser.jobNumber3?this.bindingUser.jobNumber3:'',
						jobNumber4: this.bindingUser.jobNumber4?this.bindingUser.jobNumber4:'',
						jobNumber5: this.bindingUser.jobNumber5?this.bindingUser.jobNumber5:''
					}
				}
				this.cncUnDone = true
			},
			// 该函数来循环检测扫码输入框的输入
			circlemachine() {
				if(this.workCenter != '数控车间' && this.workCenter != '焊接车间' && this.workCenter != '喷涂车间') return
				this.cncUnDone = false
				this.findPlanMachineSuccess = false
				if(!this.machineForm.deviceBarcode) {
					this.step = -1
					this.$refs.uToast.show({
							title: '流转条码不能为空！',
							type: 'error',
							icon: true
					})
					return
				}
				const v1 = this.machineForm.deviceBarcode;
				let _this = this
				setTimeout( function() {
					const v2 = _this.machineForm.deviceBarcode
					if(v1 == v2){
						_this.disabledMachine = true
						// _this.cncUnDone = true
						_this.findPlanMachine()
					}
				}, 300)
			},
			// 验证设备条码
			async findPlanMachine(){
				this.upperLimit = 0
				let { data } = await findPlanMachine({deviceBarcode: this.machineForm.deviceBarcode})
				this.disabledMachine = false
				if(data.code == '1') {
					this.findPlanMachineSuccess = true
					if(!data.data.length && this.workCenter !== '喷涂车间'){
						this.$refs.uToast.show({
							title: '流转条码获取工单绑定人数为空！请在后台的工单查询修改删除界面查询这个工单是否绑定该机台。',
							type: 'error',
							icon: true
						})
						let that = this
						setTimeout( function() {
							that.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
						}, 300)
						return
					}
					if(this.workCenter == '喷涂车间'){
						this.upperLimit = this.qualityMax
					} else {
					    this.upperLimit = data.data[0].upperLimit
					}
					console.log('qualityMax',this.upperLimit);
					this.backStepzero()
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			backStepzero(){
				let bindNum = 0
				if(this.bindingUser.jobNumber){ bindNum++ }
				if(this.bindingUser.jobNumber2){ bindNum++}
				if(this.bindingUser.jobNumber3){ bindNum++}
				if(this.bindingUser.jobNumber4){ bindNum++}
				if(this.bindingUser.jobNumber5){ bindNum++}
				if(bindNum <= this.upperLimit){
					this.machineBindForm = {
						jobNumber1: this.bindingUser.jobNumber?this.bindingUser.jobNumber:'',
						jobNumber2: this.bindingUser.jobNumber2?this.bindingUser.jobNumber2:'',
						jobNumber3: this.bindingUser.jobNumber3?this.bindingUser.jobNumber3:'',
						jobNumber4: this.bindingUser.jobNumber4?this.bindingUser.jobNumber4:'',
						jobNumber5: this.bindingUser.jobNumber5?this.bindingUser.jobNumber5:''
					}
				}
				this.cncUnDone = true
				this.step = 0
			},
			// 点击绑定当前机台
			async machineBindAndUnbind(){
				if(this.upperLimit == 1){
					if(!this.machineBindForm.jobNumber1) return this.$refs.uToast.show({
							title: '员工工号不能为空！',
							type: 'error',
							icon: true
					})
				} else if(this.upperLimit == 2){
					if(!this.machineBindForm.jobNumber1 && !this.machineBindForm.jobNumber2) return this.$refs.uToast.show({
							title: '员工工号至少输入一个！',
							type: 'error',
							icon: true
					})
					
					if(this.machineBindForm.jobNumber1 == this.machineBindForm.jobNumber2) return this.$refs.uToast.show({
							title: '员工工号不能相同！',
							type: 'error',
							icon: true
					})
				} else if(this.upperLimit == 3){
					if(!this.machineBindForm.jobNumber1 && !this.machineBindForm.jobNumber2 && !this.machineBindForm.jobNumber3) return this.$refs.uToast.show({
							title: '员工工号至少输入一个！',
							type: 'error',
							icon: true
					})
					let bindNum = 0
					if(this.machineBindForm.jobNumber1){ bindNum++ }
					if(this.machineBindForm.jobNumber2){ bindNum++}
					if(this.machineBindForm.jobNumber3){ bindNum++}
					if(this.machineBindForm.jobNumber4){ bindNum++}
					if(this.machineBindForm.jobNumber5){ bindNum++}
					const keys = Object.values(this.machineBindForm)
					const f = keys.filter(item => item !== '')  // 排除空格
					// 去重
					const bool = new Set(f).size !== f.length
					if(bindNum >= 2){
						// if(this.machineBindForm.jobNumber1 == this.machineBindForm.jobNumber2 || this.machineBindForm.jobNumber1 == this.machineBindForm.jobNumber3 || this.machineBindForm.jobNumber2 == this.machineBindForm.jobNumber3 || this.machineBindForm.jobNumber1 == this.machineBindForm.jobNumber2 == this.machineBindForm.jobNumber3) return this.$refs.uToast.show({
						// 		title: '员工工号不能相同！',
						// 		type: 'error',
						// 		icon: true
						// })
						if(bool) return this.$refs.uToast.show({
								title: '员工工号不能相同！',
								type: 'error',
								icon: true
						})
					}
					
				} else if(this.upperLimit == 4){
					if(!this.machineBindForm.jobNumber1 && !this.machineBindForm.jobNumber2 && !this.machineBindForm.jobNumber3 && !this.machineBindForm.jobNumber4) return this.$refs.uToast.show({
							title: '员工工号至少输入一个！',
							type: 'error',
							icon: true
					})
					let bindNum = 0
					if(this.machineBindForm.jobNumber1){ bindNum++ }
					if(this.machineBindForm.jobNumber2){ bindNum++}
					if(this.machineBindForm.jobNumber3){ bindNum++}
					if(this.machineBindForm.jobNumber4){ bindNum++}
					if(this.machineBindForm.jobNumber5){ bindNum++}
					const keys = Object.values(this.machineBindForm)
					const f = keys.filter(item => item !== '')  // 排除空格
					// 去重
					const bool = new Set(f).size !== f.length
					if(bindNum >= 2){
							if(bool) return this.$refs.uToast.show({
								title: '员工工号不能相同！',
								type: 'error',
								icon: true
						})
					}
					
				} else if(this.upperLimit == 5){
					if(!this.machineBindForm.jobNumber1 && !this.machineBindForm.jobNumber2 && !this.machineBindForm.jobNumber3 && !this.machineBindForm.jobNumber4 && !this.machineBindForm.jobNumber5) return this.$refs.uToast.show({
							title: '员工工号至少输入一个！',
							type: 'error',
							icon: true
					})
					let bindNum = 0
					if(this.machineBindForm.jobNumber1){ bindNum++ }
					if(this.machineBindForm.jobNumber2){ bindNum++}
					if(this.machineBindForm.jobNumber3){ bindNum++}
					if(this.machineBindForm.jobNumber4){ bindNum++}
					if(this.machineBindForm.jobNumber5){ bindNum++}
					const keys = Object.values(this.machineBindForm)
					const f = keys.filter(item => item !== '')
					const bool = new Set(f).size !== f.length
					if(bindNum >= 2)	{
							if(bool) return this.$refs.uToast.show({
								title: '员工工号不能相同！',
								type: 'error',
								icon: true
						})
					}
					
				}
				let unBindList = []
				if(this.bindingUser.jobNumber && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber3 != this.bindingUser.jobNumber){
					unBindList.push(this.bindingUser.jobNumber)
				}
				if(this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber3 != this.bindingUser.jobNumber2){
					unBindList.push(this.bindingUser.jobNumber2)
				}
				if(this.bindingUser.jobNumber3 && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber3 && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber3 && this.machineBindForm.jobNumber3 != this.bindingUser.jobNumber3){
					unBindList.push(this.bindingUser.jobNumber3)
				}
				if(this.bindingUser.jobNumber4 && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber4 && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber4 && this.machineBindForm.jobNumber4 != this.bindingUser.jobNumber4){
					unBindList.push(this.bindingUser.jobNumber4)
				}
				if(this.bindingUser.jobNumber5 && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber5 && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber5 && this.machineBindForm.jobNumber5 != this.bindingUser.jobNumber5){
					unBindList.push(this.bindingUser.jobNumber5)
				}
				
				if(unBindList.length){
					console.log('需要解绑',unBindList)
					this.machineUnBindList(unBindList.join(','))
				} else {
					this.step = 1
					this.machineBindList()
				}
				
			},
			async machineUnBindList(jobNumberList){
				// console.log(jobNumberList)
				let { data } = await machineUnbindList1({machineId: this.workNum,jobNumberList})
				if(data.code == '1') {
					this.step = 1
					this.$refs.uToast.show({
						title: '解绑成功！',
						type: 'error',
						icon: true
					})
					this.getBindingUser()
					this.machineBindList()
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			async machineBindList(){
				let jobNumberList = []
				if(this.machineBindForm.jobNumber1 && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber1 != this.bindingUser.jobNumber3){
					jobNumberList.push(this.machineBindForm.jobNumber1)
				}
				if(this.machineBindForm.jobNumber2 && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber2 != this.bindingUser.jobNumber3){
					jobNumberList.push(this.machineBindForm.jobNumber2)
				}
				if(this.machineBindForm.jobNumber3 && this.machineBindForm.jobNumber3 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber3 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber3 != this.bindingUser.jobNumber3){
					jobNumberList.push(this.machineBindForm.jobNumber3)
				}
				if(this.machineBindForm.jobNumber4 && this.machineBindForm.jobNumber4 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber4 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber4 != this.bindingUser.jobNumber4){
					jobNumberList.push(this.machineBindForm.jobNumber4)
				}
				if(this.machineBindForm.jobNumber5 && this.machineBindForm.jobNumber5 != this.bindingUser.jobNumber && this.machineBindForm.jobNumber5 != this.bindingUser.jobNumber2 && this.machineBindForm.jobNumber5 != this.bindingUser.jobNumber5){
					jobNumberList.push(this.machineBindForm.jobNumber5)
				}
				if(!jobNumberList.length){
					this.cncUnDone = false
					this.step = 2
					let that = this
					setTimeout( function() {
						that.$refs.completionQuantity.$el.getElementsByTagName("input")[0].focus()
					}, 300)
					return
				}
				let { data } = await machineBindList({machineId: this.workNum,jobNumberList: jobNumberList.join(',')})
				if(data.code == '1') {
					this.cncUnDone = false
					this.step = 2
					this.getBindingUser()
					let that = this
					setTimeout( function() {
						that.$refs.completionQuantity.$el.getElementsByTagName("input")[0].focus()
					}, 300)
					this.$refs.uToast.show({
						title: '绑定成功！',
						type: 'success',
						icon: true
					})
				} else {
					await this.getBindingUser()
					await this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			
			
			// 数控车间部分 END
			
			// 判断是否为包装线、组件生产线
			// 如若任意一个工段包含在内则返回true
			judgeSectionNum(value){
				return this.sectionNoType == 1
			},
			// value为传递进来的条形码字符串，可以为扫码枪输入this.form.handleInput，也可以为手动输入this.form.value
			// 结束码只能通过扫码枪来输入
			recordData(value,code,msg) {
				const recordStr = this.serviceTime + '\xa0\xa0\xa0\xa0\xa0' + this.val + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0'
				if(this.form.value.slice(0,2) == '!~' && this.form.value.length == 8 && !isNaN(this.form.value.slice(2))){
					this.logs.push(recordStr + '结束码')
				} else {
					
					if(code){ // 喷涂上挂需要添加 成功失败提示  2024/7/29
					    if(this.logs.length){
					    	const arr = this.logs[this.logs.length-1].split('\xa0\xa0\xa0\xa0\xa0\xa0\xa0')
					    	const arr1 = arr[1].split(' ')
					       	console.log(arr)
					       	console.log(arr1)
					       if(arr1[0] == value) {
					       	   this.logs[this.logs.length-1] = recordStr + value +` `+ code + ` ` + msg
					       } else {
					           this.logs.push(recordStr + value +` `+ code + ` ` + msg)
						   }
					    } else {
					           this.logs.push(recordStr + value +` `+ code + ` ` + msg)
						   }
					} else {
					    this.logs.push(recordStr + value)
					}
				}
				if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间'){
					this.machineForm.deviceBarcode = ''
					this.machineForm.completionQuantity = ''
					if(this.workCenter == '数控车间' || this.workCenter == '焊接车间' || this.workCenter == '喷涂车间'){ this.step = -1 }
					let that = this
					setTimeout( function() {
						that.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
					}, 300)
				}
			},
			// 该函数来循环检测扫码输入框的输入
			circleDec() {
				const v1 = this.form.value;
				let _this = this
				setTimeout( function() {
					const v2 = _this.form.value
					if(v1 == v2){
						_this.disabled = true
						_this.scanRecord()
					}
				}, 300)
			},
			// EMS总装车间，该函数来循环检测扫码输入框的输入
			circleDecEms() {
				const v1 = this.emsForm.deviceBardcode;
				let _this = this
				setTimeout( function() {
					const v2 = _this.emsForm.deviceBardcode
					if(v1 == v2){
						_this.disabledems = true
						_this.validateCode()
					}
				}, 300)
			},
			JGFFconfirm(){  // 有非法字符	
				this.emsForm.deviceBardcode = ''
				this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
				this.JGFFshow = false
				this.modalshow = false
			},
			JGFFconfirm3(){ // 长度小于3
				this.emsForm.deviceBardcode = ''
				this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
				this.JGFFshow3 = false
			},
			// 校验机柜条码
			validateCode(){
				if(this.emsForm.deviceBardcode.length < 3 ) {
					this.disabledems = false
					this.JGFFshow3 = true
					return
				}
				if(!/^[0-9a-zA-Z\[\]\)\-\>\.]*$/.test(this.emsForm.deviceBardcode)) {
					this.disabledems = false
					this.JGFFshow = true
					return
				}
				if(this.workCenter == '总装车间' && this.lineType == 1){
					console.log('校验通过')
					this.chenggong()
				} else if(this.workCenter == '总装车间' && !this.ptsCodeList.sn.length){
					console.log('校验通过') //2024/7/15 下午：钣金车间没有维护SN，暂时可不校验
					this.chenggong()
				}else if((this.ptsCodeList.sn && this.ptsCodeList.sn.length)){
					    if(!this.ptsCodeList.sn.some(item => item.sn == this.emsForm.deviceBardcode)){
					    	this.disabledems = false
					    	this.emsForm.deviceBardcode = ''
					    	this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
					    	return this.$refs.uToast.show({
					    		title: '该机柜条码不存在该工单！',
					    		type: 'error',
					    		icon: true
					    	})
					    } else {
						console.log('校验通过')
						this.chenggong()
					}
				} else {
					this.disabledems = false
					this.emsForm.deviceBardcode = ''
					this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
					this.$refs.uToast.show({
						title: 'pts未提供机柜条码！',
						type: 'error',
						icon: true
					})
				}
			},
			// 机柜条码校验成功
			chenggong(){
				this.disabledems = false
				if(this.linJiObj && this.linJiObj.processOrder == parseInt(this.workNum) && this.linJiisfirst){
					this.$refs.focusLinJiNew1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.palletCodeCount){
					this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.nameplatesCodeCount) {
					this.$refs.focuspallet2.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.operationAndMaintenanceOrCodeCount) {
					this.$refs.focusYW2.$el.getElementsByTagName("input")[0].focus()
				} else if(this.validEmsFacilityBarcode.length) {
					this.$refs.focusemsFacilityBarcode.$el.getElementsByTagName("input")[0].focus()
				} else if(this.deviceCodeList.length) {
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.accessoryCodeCount && this.boolFJ) {
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.workCenter == '总装车间' && this.lineType == 1 && this.sonAccessoryCodeList.length) {	
					this.$refs.accessoryParentn.$el.getElementsByTagName("input")[0].focus()
				} else {
					this.handleBarcodeEms()
					console.log('没有下层了')
				}
			},
			// 校验临技
			circleDecEmsLinJiNew(){
				const v1 = this.deviceDarcodeLinJiNew;
				let _this = this
				setTimeout( function() {
					const v2 = _this.deviceDarcodeLinJiNew
					if(v1 == v2){
						_this.disabledemsLJ = true
						_this.validateLinJiNew()
					}
				}, 300)
			},
			async validateLinJiNew(){
				if(!this.emsForm.deviceBardcode) {
					this.deviceDarcodeLinJiNew = ''
					this.disabledemsLJ = false
					this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '请先扫机柜条码！',
						type: 'error',
						icon: true
					})
				}
				if(this.deviceDarcodeLinJiNew != this.linJiObj.deviceDarcodeLinJi) {
					this.deviceDarcodeLinJiNew = ''
					this.disabledemsLJ = false
					this.$refs.focusLinJiNew1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '该临技条码与排产工单添加的不一致！',
						type: 'error',
						icon: true
					})
				}
				let query = {
					WorkOrderNo: this.workOrderNoType.split('-')[1],
					OrderType: this.workOrderNoType.split('-')[0],
					deviceDarcode: this.emsForm.deviceBardcode.match(/06S(\S*)1P/)[1],
					deviceDarcodeLinJi: this.deviceDarcodeLinJiNew,
					processOrder: this.linJiObj.processOrder
				}
				const { data } = await saveLinJibinding(query)
				if(data.code == '1') {
					this.$refs.uToast.show({
						title: '该临技条码校验成功！',
						type: 'success',
						icon: true
					})
					this.linJiisfirst = false
				} else {
					this.deviceDarcodeLinJiNew = ''
					this.disabledemsLJ = false
					this.$refs.focusLinJiNew1.$el.getElementsByTagName("input")[0].focus()
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			// 校验栈板条码
			circleDecEmsPallet() {
				const v1 = this.emsForm.palletCode;
				let _this = this
				setTimeout( function() {
					const v2 = _this.emsForm.palletCode
					if(v1 == v2){
						_this.disabledemsP = true
						_this.validateCodePallet()
					}
				}, 300)
			},
			ZBconfirm(){  // 有非法字符
				this.emsForm.palletCode = ''
				this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
				this.ZBshow = false
			},
			ZBconfirm3(){ // 长度小于3
				this.emsForm.palletCode = ''
				this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
				this.ZBshow3 = false
			},
			// 校验栈板条码
			validateCodePallet(){
				// 判断是否有小写字母
				if(this.containsLowerCase(this.emsForm.palletCode)){
					this.emsForm.palletCode = ''
					this.disabledemsP = false
					this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
							title: '条码内不能有小写字母！',
							type: 'error',
							icon: true
						})
				}
				// if(this.ptsCodeList.pallet.length){
				// 	if(!this.ptsCodeList.pallet.some(item => item.sn == this.emsForm.palletCode)){
				// 		this.disabledemsP = false
				// 		this.emsForm.palletCode = ''
				// 		this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
				// 		return this.$refs.uToast.show({
				// 			title: '该栈板条码不存在该工单！',
				// 			type: 'error',
				// 			icon: true
				// 		})
				// 	}
				// }
				if(this.emsForm.palletCode.length < 3 ) {
					this.disabledemsP = false
					this.ZBshow3 = true
					return
				}
				if(!/^[0-9a-zA-Z\[\]\)\-\>\.]*$/.test(this.emsForm.palletCode)) {
					this.disabledemsP = false
					this.ZBshow = true
					return
				}
				if(this.workCenter == '总装车间') {
					if(!this.emsForm.palletCode.includes('HNSJG') || this.emsForm.palletCode.indexOf('HNSJG')>0){
						this.disabledemsP = false
						this.emsForm.palletCode = ''
						this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
						return this.$refs.uToast.show({
							title: '该条码不是栈板条码1！',
							type: 'error',
							icon: true
						})
					}
					let count = 0
					let string = JSON.parse(JSON.stringify(this.emsForm.palletCode))
					while(string.indexOf('HNSJG') != -1){
						count++
						let indexpic = string.indexOf('HNSJG')
						string = string.substring(indexpic+1)
					}
					if(count>1) {
						this.disabledemsP = false
						this.emsForm.palletCode = ''
						this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
						return this.$refs.uToast.show({
							title: '该栈板条码包含多个前缀HNSJG',
							type: 'error',
							icon: true	
						})
					}
				} else {    // ems车间
				    if(!this.emsForm.palletCode.includes('CHZB') || this.emsForm.palletCode.indexOf('CHZB')>0){
				    	this.disabledemsP = false
				    	this.emsForm.palletCode = ''
				    	this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
				    	return this.$refs.uToast.show({
				    		title: '该条码不是栈板条码2！',
				    		type: 'error',
				    		icon: true
				    	})
				    }	
					let count = 0
					let string = JSON.parse(JSON.stringify(this.emsForm.palletCode))
					while(string.indexOf('CHZB') != -1){
						count++
						let indexpic = string.indexOf('CHZB')
						string = string.substring(indexpic+1)
					}
					if(count>1) {
						this.disabledemsP = false
						this.emsForm.palletCode = ''
						this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
						return this.$refs.uToast.show({
							title: '该栈板条码包含多个前缀CHZB',
							type: 'error',
							icon: true
						})
					}
				}
				if(this.emsForm.palletCode.length != 18) {
					this.disabledemsP = false
					this.emsForm.palletCode = ''
					this.$refs.focuspallet1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '该栈板条码长度不对！',
						type: 'error',
						icon: true
					})
				}
				
				this.disabledemsP = false
				if(this.emsCodeCount.nameplatesCodeCount) {
					this.$refs.focuspallet2.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.operationAndMaintenanceOrCodeCount) {
					this.$refs.focusYW2.$el.getElementsByTagName("input")[0].focus()
				} else if(this.validEmsFacilityBarcode.length) {
					this.$refs.focusemsFacilityBarcode.$el.getElementsByTagName("input")[0].focus()
				} else if(this.deviceCodeList.length) {
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.accessoryCodeCount && this.boolFJ) {
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.workCenter == '总装车间' && this.lineType == 1) {
					this.$refs.accessoryParentn.$el.getElementsByTagName("input")[0].focus()
				} else {
					console.log('没有下层了')
				}
			},
			// 验证铭牌
			circleDecEmsMp(){
				const v1 = this.emsForm.nameplatesCode;
				let _this = this
				setTimeout( function() {
					const v2 = _this.emsForm.nameplatesCode
					if(v1 == v2){
						_this.disabledemsMp = true
						_this.nameplatesCodePallet()
					}
				}, 300)
			},
			// 验证铭牌
			nameplatesCodePallet(){
				if(!this.emsForm.nameplatesCode){
					this.disabledemsMp = false
					this.emsForm.nameplatesCode = ''
					return this.$refs.uToast.show({
						title: '铭牌不能为空！',
						type: 'error',
						icon: true
					})
				}
				this.disabledemsMp = false
				const items = this.codeEmsList.find(item => item.type == '铭牌')
				if(this.emsForm.nameplatesCode !== items.nameplatesCode) {
					this.disabledemsMp = false
					this.emsForm.nameplatesCode = ''
					return this.$refs.uToast.show({
						title: '该条码不是铭牌编码！',
						type: 'error',
						icon: true
					})
				}
				this.disabledemsMp = false
				if(this.emsCodeCount.operationAndMaintenanceOrCodeCount) {
					this.$refs.focusYW2.$el.getElementsByTagName("input")[0].focus()
				} else if(this.validEmsFacilityBarcode.length) {
					this.$refs.focusemsFacilityBarcode.$el.getElementsByTagName("input")[0].focus()
				} else if(this.deviceCodeList.length) {
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				}  else if(this.emsCodeCount.accessoryCodeCount) {
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				} else {
					console.log('没有下层了')
				}
			},
			// 验证运维二维码
			circleDecYW(){
				const v1 = this.emsForm.operationAndMaintenanceOrCode;
				let _this = this
				setTimeout( function() {
					const v2 = _this.emsForm.operationAndMaintenanceOrCode
					if(v1 == v2){
						_this.disabledemsYW = true
						_this.operationAndMaintenanceOrCodePallet()
					}
				}, 300)
			},
			YWconfirm(){
				this.emsForm.operationAndMaintenanceOrCode = ''
				this.$refs.focusYW2.$el.getElementsByTagName("input")[0].focus()
				this.YWshow = false
			},
			// 验证运维二维码
			operationAndMaintenanceOrCodePallet(){
				if(!this.emsForm.operationAndMaintenanceOrCode){
					this.disabledemsYW = false
					this.emsForm.operationAndMaintenanceOrCode = ''
					return this.$refs.uToast.show({
						title: '运维二维码不能为空！',
						type: 'error',
						icon: true
					})
				}
				// if(!/^[0-9a-zA-Z[`~!@#$%^&*()_+-={};':",.<>/?/*-+.]+$/.test(this.emsForm.operationAndMaintenanceOrCode)) {
				// 	this.disabledemsYW = false
				// 	this.YWshow = true
				// 	return
				// }
				this.disabledemsYW = false
				console.log('type',this.codeEmsList);
				const items = this.codeEmsList.find(item => item.type == '运维二维码')
				if(this.emsForm.operationAndMaintenanceOrCode !== items.operationAndMaintenanceOrCode) {
					this.disabledemsYW = false
					this.emsForm.operationAndMaintenanceOrCode = ''
					return this.$refs.uToast.show({
						title: '该条码不是运维二维码！',
						type: 'error',
						icon: true
					})
				}
				this.disabledemsYW = false
				if(this.validEmsFacilityBarcode.length) {
					this.$refs.focusemsFacilityBarcode.$el.getElementsByTagName("input")[0].focus()
				} else if(this.deviceCodeList.length) {
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				} else if(this.emsCodeCount.accessoryCodeCount) {
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				} else {
					console.log('没有下层了')
				}
			},
			handleKeyPress(event){
				event.preventDefault();  // 阻止表单默认事件
			},
			// 校验器件条码
			circleDecEmsDevice(e) {
				const v1 = this.emsForm.deviceCodes;
				let _this = this
				setTimeout( function() {
					const v2 =  _this.emsForm.deviceCodes
					if(v1 == v2){
						_this.disabledemsD = true
						_this.validateCodeDevice()
					}
				}, 300)
			},
			QJconfirm(){  // 有非法字符
				this.emsForm.deviceCodes = ''
				this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				this.QJshow = false
			},
			QJconfirm3(){ // 长度小于3
				this.emsForm.deviceCodes = ''
				this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				this.QJshow3 = false
			},
			countOpeningBrackets(str) {  // 判断有几个 [ 字符
			    // 使用正则表达式匹配所有的'['  
			    const matches = str.match(/\[/g);  
			    // 如果没有匹配项，则返回0，否则返回匹配项的数量  
			    return matches ? matches.length : 0;  
			},
			// 判断是否有小写
			containsLowerCase(str) {  
			  for (let i = 0; i < str.length; i++) {  
			    const charCode = str.charCodeAt(i);  
			    if (charCode >= 97 && charCode <= 122) {  
			      // 找到了一个小写字母  
			      return true;  
			    }  
			  }  
			  // 没有找到小写字母  
			  return false;  
			},
			// 校验器件条码
			validateCodeDevice(index){
				// 判断是否有小写字母
				if(this.containsLowerCase(this.emsForm.deviceCodes)){
					this.disabledemsD = false
					this.emsForm.deviceCodes = ''
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
							title: '条码内不能有小写字母！',
							type: 'error',
							icon: true
						})
				}
				if(this.emsForm.deviceCodes.length < 3 ) {
					this.disabledemsD = false
					this.QJshow3 = true
					return
				}
				if(!/^[0-9a-zA-Z\[\]\)\-\>\.]*$/.test(this.emsForm.deviceCodes)) {
					this.disabledemsD = false
					this.QJshow = true
					return
				}
				if(this.countOpeningBrackets(this.emsForm.deviceCodes) > 1) {
					this.disabledemsD = false
					this.emsForm.deviceCodes = ''
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '该器件条码不能同时录入多个！',
						type: 'error',
						icon: true
					})
				}
				if(!this.deviceCodeList.some(item => !item.deviceCode)){
					if(this.accessoryCodeList.length){ this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus() }
					this.emsForm.deviceCodes = ''
					this.disabledemsD = false
					return this.$refs.uToast.show({
						title: '器件条码已完成扫码！',
						type: 'error',
						icon: true
					})
				}
				if(this.deviceCodeList.some(item => item.deviceCode == this.emsForm.deviceCodes)){
					this.emsForm.deviceCodes = ''
					this.disabledemsD = false
					this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
								title: '器件条码重复',
								type: 'error',
								icon: true
							})
				}
				let arrayCode = JSON.parse(JSON.stringify(this.deviceCodeList))
				arrayCode.forEach(item => {
					if(item.outid.substring(0,2) == '03'){ item.outid = item.outid.substring(2,item.outid.length)}
				})
				if(arrayCode.length){
					if(!arrayCode.some(item => this.emsForm.deviceCodes.includes(item.outid))){
						this.disabledemsD = false
						this.emsForm.deviceCodes = ''
						this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
						return this.$refs.uToast.show({
							title: '该器件条码不存在该工单！',
							type: 'error',
							icon: true
						})
					} else {
						arrayCode.forEach((item,index)=>{
							if(this.emsForm.deviceCodes.includes(item.outid) && parseInt(item.compositionAmount)<=1) {
								// this.deviceCodeList[index].deviceCode = this.emsForm.deviceCodes
								// this.disabledemsD = false
								// this.emsForm.deviceCodes = ''
								// this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
								// this.$refs.uToast.show({
								// 	title: '匹配成功！',
								// 	type: 'success',
								// 	icon: true
								// })
								if(arrayCode.filter(itemc => this.emsForm.deviceCodes.includes(itemc.outid)).length>1){
										var that = this
										var string3 = JSON.parse(JSON.stringify(this.emsForm.deviceCodes))
										if(that.methodIsGoon) return console.log('方法正在执行')
										that.methodIsGoon = true
										uni.showModal({
											title: '提示',
											content: string3+'，该器件条码包含多个物料编码，是否继续录入',
											success: function (res) {
												if (res.confirm) {
													that.emsCodeAndWrong(item,index,string3,'')
												} else if (res.cancel) {
													that.methodIsGoon = false
													that.disabledemsD = false
													that.emsForm.deviceCodes = ''
													that.focusdevicesCode1()
													console.log('用户点击取消');
												}
											}
										});
										return console.log('包含多个物料编码1')
								}
								let string4 = JSON.parse(JSON.stringify(this.emsForm.deviceCodes))
								this.emsCodeAndWrong(item,index,string4,'')
							} else if(this.emsForm.deviceCodes.includes(item.outid) && parseInt(item.compositionAmount)>1){
								let inone = false
								if(!item.deviceCode){
									// this.deviceCodeList[index].deviceCode = this.emsForm.deviceCodes
									// item.deviceCode = this.emsForm.deviceCodes
									// this.disabledemsD = false
									// this.emsForm.deviceCodes = ''
									// this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
									// this.$refs.uToast.show({
									// 	title: '匹配成功！',
									// 	type: 'success',
									// 	icon: true
									// })
									inone = true
									if(arrayCode.filter(itemc => this.emsForm.deviceCodes.includes(itemc.outid)).length>parseInt(item.compositionAmount)){
										var that = this
										var string3 = JSON.parse(JSON.stringify(this.emsForm.deviceCodes))
										if(that.methodIsGoon) return console.log('方法正在执行2')
										that.methodIsGoon = true
										console.log('执行方法emsCodeAndWrong之前',index)
										uni.showModal({
											title: '提示',
											content: string3+'，该器件条码包含多个物料编码，是否继续录入',
											success: function (res) {
												if (res.confirm) {
													that.emsCodeAndWrong(item,index,string3,'compositionAmount2')
												} else if (res.cancel) {
													that.methodIsGoon = false
													that.disabledemsD = false
													that.emsForm.deviceCodes = ''
													that.focusdevicesCode1()
													console.log('用户点击取消');
												}
											}
										});
										return console.log('包含多个物料编码2')
									}
									let string4 = JSON.parse(JSON.stringify(this.emsForm.deviceCodes))
									this.emsCodeAndWrong(item,index,string4,'compositionAmount2')
								} else if(arrayCode.some(item => this.emsForm.deviceCodes.includes(item.outid) && !item.deviceCode)) {
									// console.log('进去1')
									// for(let j = 1;j<parseInt(item.compositionAmount);j++){
									// 	if(!this.deviceCodeList[index+j].deviceCode){
									// 		this.deviceCodeList[index+j].deviceCode = this.emsForm.deviceCodes
									// 		item.deviceCode = this.emsForm.deviceCodes
									// 		this.disabledemsD = false
									// 		this.emsForm.deviceCodes = ''
									// 		this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
									// 		this.$refs.uToast.show({
									// 			title: '匹配成功！',
									// 			type: 'success',
									// 			icon: true
									// 		})
									// 		return
									// 	}
									// }
									if(inone) return console.log('进去2不能进去1')
									console.log('进去1')
									if(arrayCode.filter(itemc => this.emsForm.deviceCodes.includes(itemc.outid)).length>parseInt(item.compositionAmount)){
										var that = this
										var string3 = JSON.parse(JSON.stringify(this.emsForm.deviceCodes))
										if(that.methodIsGoon1) return console.log('方法正在执行1')
										that.methodIsGoon1 = true
										uni.showModal({
											title: '提示',
											content: string3+'，该器件条码包含多个物料编码，是否继续录入',
											success: function (res) {
												if (res.confirm) {
													that.emsCodeAndWrong1(item,index,string3)
												} else if (res.cancel) {
													that.methodIsGoon1 = false
													that.disabledemsD = false
													that.emsForm.deviceCodes = ''
													that.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
													console.log('用户点击取消');
												}
											}
										});
										return console.log('包含多个物料编码2')
									}
									let string4 = JSON.parse(JSON.stringify(this.emsForm.deviceCodes))
									this.emsCodeAndWrong1(item,index,string4)
									
							} else {
								this.disabledemsD = false
								this.emsForm.deviceCodes = ''
								console.log('匹配完成')
								this.$refs.uToast.show({
									title: '该系列条码匹配完成！',
									type: 'error',
									icon: true
								})
							}
			
								
							}
						})
					}
				} else {
					this.$refs.uToast.show({
						title: '条码校验失败！',
						type: 'error',
						icon: true
					})
				}
				this.emsForm.deviceCodes = ''
				this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
				if(!this.deviceCodeList.some(item => !item.deviceCode)) return this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
			},
			focusdevicesCode1(){
				let _this = this
				setTimeout( function() {
					_this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
					if(!_this.deviceCodeList.some(item => !item.deviceCode)) return _this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				}, 300)
			},
			// 效验重量
			circleDecEmsWeight(){
				const v1 = this.emsForm.weight;
				let _this = this
				setTimeout( function() {
					const v2 = _this.emsForm.weight
					if(v1 == v2){
						_this.disabledemsB = true
						_this.validateLinWeight()
					}
				}, 300)
			},
			validateLinWeight(){
				// console.log(this.ptsCodeList.attachment);
				if(!this.emsForm.accessoryCodes) {
					this.emsForm.weight = ''
					this.disabledemsB = false
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '请输入条码！',
						type: 'error',
						icon: true
					})
				}
				if(!/^[0-9.]+$/.test(this.emsForm.weight)) {
					this.emsForm.weight = ''
					this.disabledemsB = false
					this.$refs.accessoryWeight.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '重量必须是数字',
						type: 'error',
						icon: true
					})
				}
				// console.log(this.emsForm.weight);
				let attachment = JSON.parse(JSON.stringify(this.ptsCodeList.attachment))
				console.log(1111,attachment,attachment.length);			
				if(attachment && attachment.length > 0){
			        const items = attachment.filter(item => this.emsForm.accessoryCodes.includes(item.outid))
					console.log('items',items);	
					if(items[0].standardWeight == null) {   
						this.emsForm.weight = ''
						this.disabledemsB = false
						this.$refs.accessoryWeight.$el.getElementsByTagName("input")[0].focus()
						return this.$refs.uToast.show({
							title: '该重量没维护，请先维护！',
							type: 'error',
							icon: true
						})
					}
				    console.log(parseFloat(items[0].standardWeight)-parseFloat(items[0].weightRange));
				    console.log(parseFloat(items[0].standardWeight)+parseFloat(items[0].weightRange));
				    if(this.emsForm.weight < parseFloat(items[0].standardWeight)-parseFloat(items[0].weightRange) || this.emsForm.weight > parseFloat(items[0].standardWeight)+parseFloat(items[0].weightRange)){
				    	console.log('失败');
				    	this.emsForm.weight = ''
				    	this.disabledemsB = false
				    	this.$refs.accessoryWeight.$el.getElementsByTagName("input")[0].focus()
				    	return this.$refs.uToast.show({
				    		title: '重量不对',
				    		type: 'error',
				    		icon: true
				    	})
				    } else{	
				    	attachment.forEach((item,index) =>{
				    		if(this.emsForm.accessoryCodes.includes(item.outid)){
				    	   console.log('成功');
				    	   this.emsForm.weight = ''
				    	   this.disabledemsB = false
				    	   let string4 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
				    	   this.emsCodeAndWrong2(item,index,string4)
				    	    }
				    	})
				    }
				} else {
					console.log(this.ptsCodeList);
					console.log(attachment);
					this.emsForm.weight = ''
					this.disabledemsB = false
					this.$refs.accessoryWeight.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '没有维护重量',
						type: 'error',
						icon: true
					})
				}
			},
			// 校验包附件条码
			inputParent(){
				const v1 = this.emsForm.parentCode;
				let _this = this
				setTimeout( function() {
					const v2 =  _this.emsForm.parentCode
					if(v1 == v2){
						_this.parentDisabledems = true
						_this.validateParent()
					}
				}, 300)
			},
			validateParent(){
				if(!this.sonAccessoryCodeList.some(item => !item.parentCode)){
					this.emsForm.parentCode = ''
					this.parentDisabledems = false
					this.$refs.accessoryParentn.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '附件包已完成扫码！',
						type: 'error',
						icon: true
					})
				}	
				if(!this.sonAccessoryCodeList.some(item => this.emsForm.parentCode == item.descript)){
					this.emsForm.parentCode = ''
					this.parentDisabledems = false
					this.$refs.accessoryParentn.$el.getElementsByTagName("input")[0].focus()
				    return this.$refs.uToast.show({
				    	title: '该附件包不存在该工单!',
				    	type: 'error',
				    	icon: true
				    })
				}
				if(this.sonAccessoryCodeList.some(item => item.parentCode == this.emsForm.parentCode)){
				this.emsForm.parentCode = ''
				this.parentDisabledems = false
				this.$refs.accessoryParentn.$el.getElementsByTagName("input")[0].focus()
				return this.$refs.uToast.show({
							title: '附件条码重复',
							type: 'error',
							icon: true
						})
				}
				// 成功
				this.sonAccessoryCodeList.forEach(item => {
						if(item.descript == this.emsForm.parentCode){	
						item.parentCode = this.emsForm.parentCode
						// this.focusaccessoryCodes()
						}
				})
				this.parentDisabledems = false
				this.emsForm.parentCode = ''
				this.$refs.accessorySon.$el.getElementsByTagName("input")[0].focus()
				this.$refs.uToast.show({
					title: '匹配成功！',
					type: 'success',
					icon: true
				})
				console.log('11',this.sonAccessoryCodeList);
			},
			// 校验子附件条码
			inputSon(){
				const v1 = this.emsForm.sonCode;
				let _this = this
				setTimeout( function() {
					const v2 =  _this.emsForm.sonCode
					if(v1 == v2){
						_this.sonDisabledems = true
						_this.validateSon()
					}
				}, 300)
			},
			validateSon(){
				if(!this.sonAccessoryCodeList.some(item => !item.deviceCode)){
					this.emsForm.sonCode = ''
					this.sonDisabledems = false
					this.$refs.accessorySon.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '附件条码已完成扫码！',
						type: 'error',
						icon: true
					})
				}
				if(!this.sonAccessoryCodeList.some(item => this.emsForm.sonCode == item.outid)){
					this.emsForm.sonCode = ''
					this.sonDisabledems = false
					this.$refs.accessorySon.$el.getElementsByTagName("input")[0].focus()
				    return this.$refs.uToast.show({
				    	title: '该附件条码不存在该工单!',
				    	type: 'error',
				    	icon: true
				    })
				}
				if(this.sonAccessoryCodeList.some(item => item.deviceCode == this.emsForm.sonCode)){
				this.emsForm.sonCode = ''
				this.sonDisabledems = false
				this.$refs.accessorySon.$el.getElementsByTagName("input")[0].focus()
				return this.$refs.uToast.show({
							title: '附件条码重复',
							type: 'error',
							icon: true
						})
				}
				// 成功
				for(let i = 0; i <= this.sonAccessoryCodeList.length; i++){
							console.log(this.sonAccessoryCodeList[i])
						if(this.sonAccessoryCodeList[i].outid == this.emsForm.sonCode){
						this.sonAccessoryCodeList[i].deviceCode = this.emsForm.sonCode
						// item.deviceCode = deviceCodes
						this.sonDisabledems = false
						this.emsForm.sonCode = ''
						// this.focusaccessoryCodes()
						this.$refs.uToast.show({
							title: '匹配成功！',
							type: 'success',
							icon: true
						})
							return
						}
				}	
				
			},
			// 校验附件条码
			circleDecEmsAttach() {
				const v1 = this.emsForm.accessoryCodes;
				let _this = this
				setTimeout( function() {
					const v2 =  _this.emsForm.accessoryCodes
					if(v1 == v2){
						_this.disabledemsA = true
						_this.validateCodeAttach()
					}
				}, 300)
			},
			FJconfirm(){
				this.emsForm.accessoryCodes = ''
				this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				this.FJshow = false
			},
			// 钣金装配
			plateAssemble(){
				for(let i = 0; i <= this.accessoryCodeList.length; i++){
							console.log(this.accessoryCodeList[i])
						if(!this.accessoryCodeList[i].deviceCode){
							this.accessoryCodeList[i].deviceCode = this.emsForm.accessoryCodes
						// item.deviceCode = deviceCodes
						this.disabledemsA = false
						this.emsForm.accessoryCodes = ''
						this.focusaccessoryCodes()
						this.$refs.uToast.show({
							title: '匹配成功！',
							type: 'success',
							icon: true
						})
							return
						}
				}	
			},
			// 校验附件条码
			validateCodeAttach(){
				// 判断是否有小写字母
				if(this.containsLowerCase(this.emsForm.accessoryCodes)){
					this.emsForm.accessoryCodes = ''
					this.disabledemsA = false
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
							title: '条码内不能有小写字母！',
							type: 'error',
							icon: true
						})
				}
				if(!this.accessoryCodeList.some(item => !item.deviceCode)){
					this.emsForm.accessoryCodes = ''
					this.disabledemsA = false
					this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
					return this.$refs.uToast.show({
						title: '附件条码已完成扫码！',
						type: 'error',
						icon: true
					})
				}
				if(!/^[0-9a-zA-Z\[\]\)\-\>\.]*$/.test(this.emsForm.accessoryCodes)) {
					this.disabledemsA = false
					this.FJshow = true
					return
				}
				// if(this.workCenter == '总装车间' && this.lineType == 2){
				// 	this.plateAssemble()  // 钣金装配
				// 	return
				// }
				if(this.accessoryCodeList.some(item => item.deviceCode == this.emsForm.accessoryCodes)){
				this.emsForm.accessoryCodes = ''
				this.disabledemsA = false
				this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				return this.$refs.uToast.show({
							title: '附件条码重复',
							type: 'error',
							icon: true
						})
				}
				let arrayCode = JSON.parse(JSON.stringify(this.accessoryCodeList))
				if(arrayCode.length){
					if(this.workCenter == '总装车间' && this.lineType == 2){   // 钣金校验
						// if(!arrayCode.some(item => this.emsForm.accessoryCodes == item.code)){
						// 	this.disabledemsA = false
						// 	this.emsForm.accessoryCodes = ''
						// 	this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
						// 	return this.$refs.uToast.show({
						// 		title: '该附件条码不存在该工单！',
						// 		type: 'error',
						// 		icon: true
						// 	})
						// } else{
							// 与SN接口的所有附件包做匹配
							if(!this.attachmentBags.some(item => this.emsForm.accessoryCodes == item)){
								this.disabledemsA = false
								this.emsForm.accessoryCodes = ''
								this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
						        return this.$refs.uToast.show({
						        	title: '该附件条码不存在该工单!',
						        	type: 'error',
						        	icon: true
						        })
							}
							this.plateAssemble()
							return
							// } // 钣金校验成功
					}else if(!arrayCode.some(item => this.emsForm.accessoryCodes.includes(item.outid))){
						this.disabledemsA = false
						this.emsForm.accessoryCodes = ''
						this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
						return this.$refs.uToast.show({	
							title: '该附件条码不存在该工单！',
							type: 'error',
							icon: true
						})
					} else {
						arrayCode.forEach((item,index)=>{
							if(this.emsForm.accessoryCodes.includes(item.outid)) {
								if(arrayCode.filter(itemc => this.emsForm.accessoryCodes.includes(itemc.outid)).length>1){
										var that = this
										var string3 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
										if(that.methodIsGoon2) return console.log('方法正在执行1，附件')
										that.methodIsGoon2 = true
										uni.showModal({
											title: '提示',
											content: string3+'，该附件条码包含多个物料编码，是否继续录入',
											success: function (res) {
												if (res.confirm) {
													this.ptsCodeList.attachment.forEach((item1,index) =>{
														if(this.emsForm.accessoryCodes.includes(item1.outid)){
															if(item1.standardWeight == null){
																return this.$refs.uToast.show({
																			title: '标准重量没维护，请先维护！',
																			type: 'error',
																			icon: true
																		})
																// console.log('标准重量为0或没有，不需要称重');
																// let string4 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
																// this.emsCodeAndWrong2(item,index,string4)
															}
														}
													})
												} else if (res.cancel) {
													that.methodIsGoon2 = false
													that.disabledemsD = false
													that.emsForm.accessoryCodes = ''
													that.focusaccessoryCodes()
													console.log('附件校验，用户点击取消');
												}
											}
										});
										return console.log('包含多个物料编码1，附件')
								}
								// this.disabledemsA = false
								// this.emsForm.accessoryCodes = ''
								this.ptsCodeList.attachment.forEach((item1,index) =>{
									if(this.emsForm.accessoryCodes.includes(item1.outid)){
										if(item1.standardWeight == null){
											return this.$refs.uToast.show({
														title: '标准重量没维护，请先维护！',
														type: 'error',
														icon: true
													})
										} else if(item1.standardWeight == 0){  // 维护的数量是0  就默认通过
										let string4 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
										this.emsCodeAndWrong2(item,index,string4)
										}
									}
								})
								this.$refs.accessoryWeight.$el.getElementsByTagName("input")[0].focus()
								// this.$refs.uToast.show({
								// 	title: '条码匹配成功！',
								// 	type: 'success',
								// 	icon: true
								// })
								// let string4 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
								// // 成功
								// this.emsCodeAndWrong2(item,index,string4)
							} 
						// 	else if(this.emsForm.accessoryCodes.includes(item.outid) && parseInt(item.compositionAmount)>1){
						// 			let inone1 = false
						// 			if(!item.deviceCode){
						// 				// this.accessoryCodeList[index].deviceCode = this.emsForm.accessoryCodes
						// 				// item.deviceCode = this.emsForm.accessoryCodes
						// 				// this.disabledemsA = false
						// 				// this.emsForm.accessoryCodes = ''
						// 				// this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
						// 				// this.$refs.uToast.show({
						// 				// 	title: '匹配成功！',
						// 				// 	type: 'success',
						// 				// 	icon: true
						// 				// })
						// 				console.log('进去2，附件')
						// 				inone1 = true
						// 				if(arrayCode.filter(itemc => this.emsForm.accessoryCodes.includes(itemc.outid)).length>parseInt(item.compositionAmount)){
						// 					var that = this
						// 					var string3 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
						// 					if(that.methodIsGoon3) return console.log('方法正在执行2，附件')
						// 					that.methodIsGoon3 = true
						// 					console.log('执行方法emsCodeAndWrong2之前',index)
						// 					uni.showModal({
						// 						title: '提示',
						// 						content: string3+'，该附件条码包含多个物料编码，是否继续录入',
						// 						success: function (res) {
						// 							if (res.confirm) {
						// 								that.emsCodeAndWrong2(item,index,string3)
						// 							} else if (res.cancel) {
						// 								that.methodIsGoon3 = false
						// 								that.disabledemsA = false
						// 								that.emsForm.accessoryCodes = ''
						// 								that.focusaccessoryCodes()
						// 								console.log('用户点击取消，附件');
						// 							}
						// 						}
						// 					});
						// 					return console.log('包含多个物料编码2，附件')
						// 				}
						// 				let string4 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
						// 				this.emsCodeAndWrong2(item,index,string4)
						// 			} else if(arrayCode.some(item => this.emsForm.accessoryCodes.includes(item.outid) && !item.deviceCode)) {
						// 			// for(let j = 1;j<parseInt(item.compositionAmount);j++){
						// 			// 	if(!this.accessoryCodeList[index+j].deviceCode){
						// 			// 		this.accessoryCodeList[index+j].deviceCode = this.emsForm.accessoryCodes
						// 			// 		item.deviceCode = this.emsForm.accessoryCodes
						// 			// 		this.disabledemsA = false
						// 			// 		this.emsForm.accessoryCodes = ''
						// 			// 		this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
						// 			// 		this.$refs.uToast.show({
						// 			// 			title: '匹配成功！',
						// 			// 			type: 'success',
						// 			// 			icon: true
						// 			// 		})
						// 			// 		return
						// 			// 	}
						// 			// }
						// 			if(inone1) return console.log('进去2不能进去1，附件')
						// 			console.log('进去1，附件')
						// 			if(arrayCode.filter(itemc => this.emsForm.accessoryCodes.includes(itemc.outid)).length>parseInt(item.compositionAmount)){
						// 				var that = this
						// 				var string3 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
						// 				if(that.methodIsGoon3) return console.log('方法正在执行3，附件')
						// 				that.methodIsGoon3 = true
						// 				uni.showModal({
						// 					title: '提示',
						// 					content: string3+'，该器件条码包含多个物料编码，是否继续录入',
						// 					success: function (res) {
						// 						if (res.confirm) {
						// 							that.emsCodeAndWrong3(item,index,string3)
						// 						} else if (res.cancel) {
						// 							that.methodIsGoon3 = false
						// 							that.disabledemsA = false
						// 							that.emsForm.accessoryCodes = ''
						// 							that.focusaccessoryCodes()
						// 							console.log('用户点击取消');
						// 						}
						// 					}
						// 				});
						// 				return console.log('包含多个物料编码2')
						// 			}
						// 			let string4 = JSON.parse(JSON.stringify(this.emsForm.accessoryCodes))
						// 			this.emsCodeAndWrong3(item,index,string4)
									
						// 	} else {
						// 		this.disabledemsA = false
						// 		this.emsForm.accessoryCodes = ''
						// 		console.log('匹配完成')
						// 		this.$refs.uToast.show({
						// 			title: '该系列条码匹配完成！',
						// 			type: 'error',
						// 			icon: true
						// 		})
						// 	}
						// }
						})
					}
					this.disabledemsA = false
					// this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				} else {
					this.$refs.uToast.show({
						title: '条码校验失败！',
						type: 'error',
						icon: true
					})
				}
			},
			focusaccessoryCodes(){
				let _this = this
				setTimeout( function() {
					_this.$refs.accessoryCode1.$el.getElementsByTagName("input")[0].focus()
				}, 300)
			},
			submit(){
				this.$refs.uForm.validate(valid => {
					if (valid) {
						console.log('验证通过');
						this.upForm()
					} else {
						console.log('验证失败');
					}
				});
			},
			// 工段长上传表单
			async upForm() {
				const query = {}
				query.jobNumber = this.changeForm.jobNumber
				query.password = this.changeForm.password
				query.sectionNo = this.val
				const { data } = await managerLogin(query)
				this.resMsg = data.msg
				if(data.code == '1') {
					this.$refs.uToast.show({
						title: this.resMsg,
						type: 'success',
						icon: true
					})
					// 上传成功，重新生成二维码，并且更改DOM，将工段长工号与密码清空
					this.$refs.qrcode._makeCode()
					sessionStorage.setItem("routeInfo", this.val)
					this.handleString(this.val,'continue')
					this.changeForm.jobNumber = ''
					this.changeForm.password = ''
				} else {
					this.$refs.uToast.show({
						title: this.resMsg,
						type: 'error',
						icon: true
					})
				}
			},
			// 下拉选择函数，
			actionSheetCallback(index) {
				this.selectValue = this.actionSheetList[index].text;			//将下拉选择的数据填入输入框
				this.val = this.val.substring(0,6) + this.actionSheetList[index].text;			//加上工段编号，赋值给val变量
			},
			async getProcess() {
				const query = {}
				query.stationIdentifying = this.workNum
				query.sectionNo = this.sectionNum
				const { data } = await process(query)
				if(data.code == '1') {
					if(!data.data) return
					if(data.data) {
					    this.technologyNo = data.data.technologyNo
					    this.stationIdentifying = data.data.stationIdentifying
					}
					if(data.data.length>1) {
						let arr = []
						data.data.forEach((item)=>{
							let obj = {}
							obj.name = item.stationIdentifying
							arr.push(obj)
						})
						this.workNumList = arr
					} else if(this.workCenter == 'EMS总装车间' || this.workCenter == '总装车间') {
						this.processName = data.data.processName
						this.jobNumber = data.data.wokeNumberBind
						this.staProcessOrder = data.data.staProcessOrder
					}
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			radioGroupChange(e) {
				let sopBarcode = this.sectionNum + this.workNum
				sessionStorage.setItem("routeInfo",sopBarcode)
				this.val = sopBarcode
			},
			// EMS总装车间，start
			//EMS总装车间扫码
			showComplete(item){
				this.contentEms = item.descript
				this.showContentEms = true
			},
			async findLinJi(val,val1) {
				const query = {
					WorkOrderNo: val,
					OrderType: val1
				}
				const { data } = await findLinJi(query)
				if(data.code == '1') {
					this.linJiObj = data.data
					if(data.data){
						if(data.data.deviceDarcodeLinJiNew){
							this.linJiisfirst = false
						}
					}
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			async getEmsFacilityBarcode(val) {
				const query = {
					facilityTechnologyNo: val.technologyNo,
					facilityProcess: val.processOrder,
					page: 1,
					limit: 1000
				}
				const { data } = await getEmsFacilityBarcode(query)
				if(data.code == '1') {
					this.validEmsFacilityBarcode = data.data.list
					console.log(111111,this.validEmsFacilityBarcode);
					// 回显 工装设备条码  2024-8-29
					if(this.validEmsFacilityBarcode.length){
					    const elm = JSON.parse(sessionStorage.getItem('emsFacilityBarcode'))
					    console.log('回显工装设备条码',elm)
					    if(elm.sectionNum == this.sectionNum + this.workNum && elm.workOrderNoType == this.workOrderNoType){
					    	this.emsFacilityBarcode = elm.emsFacilityBarcode
					    }
					}
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			async handleBarcodeEms(){
				if(!this.emsForm.deviceBardcode) return this.$refs.uToast.show({
					title: '机柜条码不能为空！',
					type: 'error',
					icon: true
				})
				if(!this.emsForm.palletCode && this.emsCodeCount.palletCodeCount) return this.$refs.uToast.show({
					title: '栈板条码不能为空！',
					type: 'error',
					icon: true
				})
				if(!this.emsForm.nameplatesCode && this.emsCodeCount.nameplatesCodeCount) return this.$refs.uToast.show({
					title: '铭牌不能为空！',
					type: 'error',
					icon: true
				})
				if(!this.emsForm.operationAndMaintenanceOrCode && this.emsCodeCount.operationAndMaintenanceOrCodeCount) return this.$refs.uToast.show({
					title: '运维二维码不能为空！',
					type: 'error',
					icon: true
				})
				if(this.deviceCodeList.length){ 
					if(this.deviceCodeList.some(item => !item.deviceCode)) return this.$refs.uToast.show({
					title: '器件条码未扫码完成！',
					type: 'error',
					icon: true
				})}
				if(this.accessoryCodeList.length){
					if(this.accessoryCodeList.some(item => !item.deviceCode)) return this.$refs.uToast.show({
					title: '附件条码未扫码完成！',
					type: 'error',
					icon: true
				})}
				if(this.emsCodeCount.deviceCodeCount && !this.deviceCodeList.length) return this.$refs.uToast.show({
					title: '器件条码表格资料未完善！',
					type: 'error',
					icon: true
				})
				if(this.workCenter !== '总装车间' && this.lineType !== 1){
				    if(this.emsCodeCount.accessoryCodeCount && !this.accessoryCodeList.length) return this.$refs.uToast.show({
				    	title: '附件条码表格资料未完善！',
				    	type: 'error',
				    	icon: true
				    })
				}
				if(this.emsrequest) return this.$refs.uToast.show({
					title: '请求过于频繁！',
					type: 'error',
					icon: true
				})
				// 2024-8-8去掉了校验 （原因：不需要了）
				if(this.validEmsFacilityBarcode.length) {
					// const res = this.validEmsFacilityBarcode.some(item => !this.emsFacilityBarcode.includes((item.facilityBarcodeType1+'-'+item.facilityBarcodeType2+'-'+item.facilityBarcodeType3)))
					// console.log(res);
					// if(this.validEmsFacilityBarcode.some(item => !this.emsFacilityBarcode.includes(item.facilityBarcodeType1+'-'+item.facilityBarcodeType2))) return this.$refs.uToast.show({
					// 	title: '工装设备条码校验失败！请检查该工装设备条码是否存在该品号！',
					// 	type: 'error',
					// 	icon: true
					// })
					// 工装条码   2024-8-29  校验两个 - 才正确
					if(!/-.*?-/.test(this.emsFacilityBarcode)) return this.$refs.uToast.show({
						title: '工装设备条码校验失败！请检查该工装设备条码是否存在该品号！',
						type: 'error',
						icon: true
					})
					this.emsForm.emsFacilityBarcode = this.emsFacilityBarcode
				}
				if(this.workCenter == '总装车间' && this.lineType == 1){
					if(this.sonAccessoryCodeList.length){
						if(this.sonAccessoryCodeList.some(item => !item.deviceCode)) return this.$refs.uToast.show({
						title: '附件条码未扫码完成！',
						type: 'error',
						icon: true
					})}
					if(this.sonAccessoryCodeList.length){
						if(this.sonAccessoryCodeList.some(item => !item.parentCode)) return this.$refs.uToast.show({
						title: '附件条码未扫码完成！',
						type: 'error',
						icon: true
					})}
				}
				// 判断是否有乱码
				// console.log(this.deviceCodeList);
				// for(let item of this.deviceCodeList) {
				// 	const lm = ['','','']
				// 	const bool = lm.some(lmItem => item.deviceCode.includes(lmItem))
				// 	if (bool) {
				// 		this.$refs.uToast.show({
				// 			title: '条码有出现乱码问题，不能提交！',
				// 			type: 'error',
				// 			icon: true
				// 		})
				// 		return
				// 	}
				// }
				this.emsrequest = true
				let _this = this
				setTimeout( function() {
					_this.emsrequest = false
				}, 1000)
				let query = Object.assign({},this.emsForm)
				delete query.deviceCodes
				delete query.accessoryCodes
				if(this.deviceCodeList.length){
					let array = []
					let outidarray = []
					if(this.workCenter == '总装车间'){
						this.deviceCodeList.forEach(item=>{
							array.push(item.deviceCode)
							outidarray.push(item.outid)
						})
					} else {
					    this.deviceCodeList.forEach(item=>{
							 if(item.deviceCode.includes('06S')){
					    		array.push(item.deviceCode.match(/06S(\S*)1P/)[1])
					    	} else { array.push(item.deviceCode) }
					    	outidarray.push(item.outid)
					    })
					}
					query.deviceCode = array.join(',')
					query.outid = outidarray.join(',')
				} else { delete query.deviceCode }
				if(this.accessoryCodeList.length) {
					let array1 = []
					this.accessoryCodeList.forEach(item=>{ array1.push(item.deviceCode) })
					query.accessoryCode = array1.join(',')
				} else { delete query.accessoryCode }
				if(!this.emsCodeCount.palletCodeCount) { delete query.palletCode }
				query.sopBarcode = this.sectionNum + this.workNum
				if(this.workCenter == '总装车间') {
					if(this.lineType == 1) {	
						console.log('组件');
					    query.stationIdentifying = this.emsForm.deviceBardcode
					    query.barCode = this.sectionNum + this.workNum
					    delete query.deviceBardcode
					    delete query.sopBarcode
					} else {
						console.log('钣金其他线体类型');
					}
				} else {
					if(query.deviceBardcode.includes('06S')){query.deviceBardcode = query.deviceBardcode.match(/06S(\S*)1P/)[1]}
				}
				// query = {
				// 	sopBarcode: '01067409',
				// 	deviceBardcode: '6Y2410004124',
				// 	deviceCode:  "[)>06SBT23A00566861P0302025775,[)>06SBT23901707821P0302025775",
				// }
				// 校验字符长度
				// if(this.deviceCodeList.length){
				//     let obj = {
				//     	materialCodes: ''
				//     }
				//     let arr = JSON.parse(JSON.stringify(this.deviceCodeList))
				//     let outidarray = []
				//     arr.forEach(items=>{
				//     	if(items.deviceCode.includes('06S')){
				//     		items.deviceCode = items.deviceCode.match(/06S(\S*)1P/)[1]
				//     	} else { items.deviceCode = items.deviceCode }
				//     	outidarray.push(items.outid)
				//     })
				//     obj.materialCodes = outidarray.join(',')
				//     const res = await selMaterialCodeLen(obj)
				//     console.log(res);
				//     if(res.data.data.length){
				//     	for(let item of res.data.data){
				//     		let deviceCodeList = this.deviceCodeList
				//     		this.deviceCodeList = []
				//     		for(let [index, obj] of deviceCodeList.entries()) {
				//     			if(item.materialCode == obj.outid){
				//     				let code = ''
				//     				if(obj.deviceCode.includes('06S')){
				//     					code = obj.deviceCode.match(/06S(\S*)1P/)[1]
				//     				} else { code = obj.deviceCode }
				//     				if(item.len != code.length){
				//     					console.log(item.len,code,code.length);
				//     					this.$set(deviceCodeList[index],'deviceCode','')
				//     					this.deviceCodeList = deviceCodeList
				//     					// this.deviceCodeList[index].deviceCode = ''
				//     					this.modalshow = true
				//     					this.content = `${obj.outid}编码长度错误，正确长度为${item.len}位, 该录入的条码: ${code} 是${code.length}位`
				//     					return
				//     					// return this.$refs.uToast.show({
				//     					// 	title: `${obj.outid} 条码长度错误，正确长度是${item.len}位, 该录入的条码: ${code}`,
				//     					// 	type: 'warning',
				//     					// 	icon: true
				//     					// })
				//     				}
				//     			}
				//     		}
				//     		this.deviceCodeList = deviceCodeList
				//     	}
				//     }
				// }
				console.log('query',query)
				if(this.workCenter == '总装车间' && this.lineType == 1){
					// query.accessoryCodeBag // 附件包
					// query.accessoryCode // 附件
					let array = []
					let outidarray = []
					this.sonAccessoryCodeList.forEach(item=>{
						array.push(item.deviceCode)
						outidarray.push(item.parentCode)
					})
					query.accessoryCode = array.join(',')
					query.accessoryCodeBag = outidarray.join(',')
					console.log('附件',query.accessoryCode)
					console.log('附件包',query.accessoryCode)
				}	
				const { data } = this.workCenter == '总装车间' && this.lineType == 1 ? await userScan(query) : this.workCenter == '总装车间' ? await sopScan(query) : await emsScan(query)
				if(this.workCenter == '总装车间'){  // 钣金车间只需要扫一个器件条码的时候
					this.emsForm.deviceBardcode = ''
					this.$refs.inputValues.$el.getElementsByTagName("input")[0].focus()
				}
				console.log('上传成功',data);
				if(data.code == '1') {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'success',
						icon: true
					})
					// 存储	工装设备条码 2024-8-29
					if(this.validEmsFacilityBarcode.length) {
					    const res = {
					    	emsFacilityBarcode: this.emsFacilityBarcode,
					    	workOrderNoType: this.workOrderNoType,        // 工单
					    	sectionNum: this.sectionNum + this.workNum,   // 工段
					    }
					    sessionStorage.setItem('emsFacilityBarcode',JSON.stringify(res))  
					}
					this.emsForm = {
						deviceBardcode: '',
						palletCode: '',
						deviceCode: ''
					}
					// this.emsFacilityBarcode = ''        // 工装设备条码
					this.deviceCodeList.forEach(item=>{ item.deviceCode = '' })
					this.accessoryCodeList.forEach(item=>{ item.deviceCode = '' })
					this.emsForm.palletCode = ''
					this.emsForm.deviceBardcode = ''
					this.serviceTime = data.data == null ? '' : data.data
					if(!query.deviceBardcode) {
						query.deviceBardcode = query.stationIdentifying
					}
					this.recordData(query.deviceBardcode)
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error',
						icon: true
					})
				}
			},
			emsCodeAndWrong(item,index,deviceCodes,type){
				// console.log(deviceCodes);
				// const tihuan = ['','',' ']
				// const str = new RegExp(tihuan.join('|'),'g')
				// deviceCodes = deviceCodes.replace(str,'')
				// console.log(deviceCodes);
				if(this.methodIsGone) return console.log('emsCodeAndWrong方法在执行中')
				this.methodIsGone = true
				console.log('多个物料编码123',index,item,deviceCodes,type)
				let count = 0
				let string = JSON.parse(JSON.stringify(deviceCodes))
				while(string.indexOf(item.outid) != -1){
					count++
					let indexpic = string.indexOf(item.outid)
					string = string.substring(indexpic+1)
				}
				if(count>1){
						var that = this
						let string3 = JSON.parse(JSON.stringify(deviceCodes))
						uni.showModal({
							title: '提示',
							content: deviceCodes+',该器件条码包含相同的物料编码',
							success: function (res) {
								if (res.confirm) {
									that.methodIsGoon = false
									that.methodIsGone = false
									that.deviceCodeList[index].deviceCode = string3
									that.disabledemsD = false
									that.emsForm.deviceCodes = ''
									that.focusdevicesCode1()
									that.$refs.uToast.show({
										title: '匹配成功！',
										type: 'success',
										icon: true
									})
								} else if (res.cancel) {
									that.methodIsGoon = false
									that.methodIsGone = false
									that.disabledemsD = false
									that.emsForm.deviceCodes = ''
									that.focusdevicesCode1()
									console.log('用户点击取消');
								}
							}
						});
						return console.log('重复物料编码')
				}
				this.methodIsGoon = false
				this.methodIsGone = false
				this.deviceCodeList[index].deviceCode = deviceCodes
				item.deviceCode = deviceCodes
				this.disabledemsD = false
				this.emsForm.deviceCodes = ''
				this.focusdevicesCode1()
				this.$refs.uToast.show({
					title: '匹配成功！',
					type: 'success',
					icon: true
				})
				
			},
			emsCodeAndWrong1(item,index,deviceCodes){
				if(this.methodIsGone1) return console.log('emsCodeAndWrong1方法正在执行中')
				this.methodIsGone1 = true
				console.log('emsCodeAndWrong1',index)
				let count = 0
				let string = JSON.parse(JSON.stringify(deviceCodes))
				while(string.indexOf(item.outid) != -1){
					count++
					let indexpic = string.indexOf(item.outid)
					string = string.substring(indexpic+1)
				}
				if(count>1){
						var that = this
						let string3 = JSON.parse(JSON.stringify(deviceCodes))
						uni.showModal({
							title: '提示',
							content: deviceCodes+',该器件条码包含相同的物料编码',
							success: function (res) {
								if (res.confirm) {
									for(let j = 1;j<parseInt(item.compositionAmount);j++){
										if(!that.deviceCodeList[index+j].deviceCode){
											that.deviceCodeList[index+j].deviceCode = string3
											item.deviceCode = string3
											that.methodIsGoon1 = false
											that.methodIsGone1 = false
											that.disabledemsD = false
											that.emsForm.deviceCodes = ''
											that.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
											that.$refs.uToast.show({
												title: '匹配成功！',
												type: 'success',
												icon: true
											})
											return
										}
									}
								} else if (res.cancel) {
									that.methodIsGoon1 = false
									that.methodIsGone1 = false
									that.disabledemsD = false
									that.emsForm.deviceCodes = ''
									that.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
									console.log('用户点击取消');
								}
							}
						});
						return console.log('重复物料编码')
				}
				for(let j = 1;j<parseInt(item.compositionAmount);j++){
					if(!this.deviceCodeList[index+j].deviceCode){
						this.deviceCodeList[index+j].deviceCode = deviceCodes
						item.deviceCode = deviceCodes
						this.methodIsGoon1 = false
						this.methodIsGone1 = false
						this.disabledemsD = false
						this.emsForm.deviceCodes = ''
						this.$refs.devicesCode1.$el.getElementsByTagName("input")[0].focus()
						this.$refs.uToast.show({
							title: '匹配成功！',
							type: 'success',
							icon: true
						})
						return
					}
				}
			},
			emsCodeAndWrong2(item,index,deviceCodes){
				if(this.methodIsGone2) return console.log('emsCodeAndWrong2方法在执行中')
				this.methodIsGone2 = true
				console.log('多个物料编码1，附件',index)
				let count = 0
				let string = JSON.parse(JSON.stringify(deviceCodes))
				while(string.indexOf(item.outid) != -1){
					count++
					let indexpic = string.indexOf(item.outid)
					string = string.substring(indexpic+1)
				}
				if(count>1){
						var that = this
						let string3 = JSON.parse(JSON.stringify(deviceCodes))
						uni.showModal({
							title: '提示',
							content: deviceCodes+',该附件条码包含相同的物料编码',
							success: function (res) {
								if (res.confirm) {
									that.methodIsGoon2 = false
									that.methodIsGone2 = false
									// that.accessoryCodeList[index].deviceCode = string3
									that.accessoryCodeList.forEach((items,id) => {
										if(this.weight =='总装车间' && this.lineType == 2){
											if(items.code === item.attachmentBag){
												that.accessoryCodeList[id].deviceCode = deviceCodes
											}
										}else if(items.outid === item.outid){
											that.accessoryCodeList[id].deviceCode = deviceCodes
										}
									})
									that.disabledemsA = false
									that.emsForm.accessoryCodes = ''
									that.focusaccessoryCodes()
									that.$refs.uToast.show({
										title: '匹配成功！',
										type: 'success',
										icon: true
									})
								} else if (res.cancel) {
									that.methodIsGoon2 = false
									that.methodIsGone2 = false
									that.disabledemsA = false
									that.emsForm.accessoryCodes = ''
									that.focusaccessoryCodes()
									console.log('用户点击取消，附件');
								}
							}
						});
						return console.log('重复物料编码，附件')
				}
				this.methodIsGoon2 = false
				this.methodIsGone2 = false
				this.accessoryCodeList.forEach((items,id) => {
					if(this.workCenter =='总装车间' && this.lineType == 2){
						if(items.code === item.attachmentBag){
							this.accessoryCodeList[id].deviceCode = deviceCodes
						}
					}else if(items.outid === item.outid){
						this.accessoryCodeList[id].deviceCode = deviceCodes
					}
				})
				item.deviceCode = deviceCodes
				this.disabledemsA = false
				this.emsForm.accessoryCodes = ''
				this.focusaccessoryCodes()
				this.$refs.uToast.show({
					title: '匹配成功！',
					type: 'success',
					icon: true
				})
			},
			emsCodeAndWrong3(item,index,deviceCodes){
				if(this.methodIsGone3) return console.log('emsCodeAndWrong3方法正在执行中')
				this.methodIsGone3 = true
				console.log('emsCodeAndWrong3',index)
				let count = 0
				let string = JSON.parse(JSON.stringify(deviceCodes))
				while(string.indexOf(item.outid) != -1){
					count++
					let indexpic = string.indexOf(item.outid)
					string = string.substring(indexpic+1)
				}
				if(count>1){
						var that = this
						let string3 = JSON.parse(JSON.stringify(deviceCodes))
						uni.showModal({
							title: '提示',
							content: deviceCodes+',该附件条码包含相同的物料编码',
							success: function (res) {
								if (res.confirm) {
									for(let j = 1;j<parseInt(item.compositionAmount);j++){
										if(!that.accessoryCodeList[index+j].deviceCode){
											that.accessoryCodeList[index+j].deviceCode = string3
											item.deviceCode = string3
											that.methodIsGoon3 = false
											that.methodIsGone3 = false
											that.disabledemsA = false
											that.emsForm.accessoryCodes = ''
											that.focusaccessoryCodes()
											that.$refs.uToast.show({
												title: '匹配成功！',
												type: 'success',
												icon: true
											})
											return
										}
									}
								} else if (res.cancel) {
									that.methodIsGoon3 = false
									that.methodIsGone3 = false
									that.disabledemsA = false
									that.emsForm.accessoryCodes = ''
									that.focusaccessoryCodes()
									console.log('用户点击取消，附件');
								}
							}
						});
						return console.log('重复物料编码')
				}
				for(let j = 1;j<parseInt(item.compositionAmount);j++){
					if(!this.accessoryCodeList[index+j].deviceCode){
						this.accessoryCodeList[index+j].deviceCode = deviceCodes
						item.deviceCode = deviceCodes
						this.methodIsGoon3 = false
						this.methodIsGone3 = false
						this.disabledemsA = false
						this.emsForm.accessoryCodes = ''
						this.focusaccessoryCodes()
						this.$refs.uToast.show({
							title: '匹配成功！',
							type: 'success',
							icon: true
						})
						return
					}
				}
			},
			// EMS总装车间，end
		},
		components: {
			tkiQrcode
		},
		// 在页面生成的时候便读取routeInfo信息，并对字符串进行截取
		onShow() {
			uni.setNavigationBarTitle({
				title: 'SOP终端系统'
			});
			this.bool = false
			// sessionStorage.setItem("routeInfo", this.$route.query.value)
			if(this.$route.query.value != undefined) {
				this.handleString(this.$route.query.value)
				sessionStorage.setItem("routeInfo", this.$route.query.value)
			} else {
				if(sessionStorage.getItem('routeInfo') != undefined) {
					this.handleString(sessionStorage.getItem('routeInfo'))
				} else {
					alert('相关工段工位信息缺失，请联系管理人员配置！')
				}
			}
			if(this.workCenter == '数控车间' || this.workCenter == '焊接车间'  || this.workCenter == '喷涂车间'){this.getBindingUser()}
			if(this.workCenter){this.scanSwitch()}
			console.log('onShow1')
			uni.setNavigationBarTitle({
				title: 'SOP终端系统'
			});
			
			
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: 'SOP终端系统'
			});
			this.val = this.$route.query.value
		},
		// 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
	}
	// 当窗口即将被卸载（关闭）时,会触发该事件.此时页面文档依然可见
	window.onbeforeunload = function(e) {
		return "确定离开此页面吗？"
	}
	
</script>

<style lang="scss" scoped>
page {
	height: 3200rpx;
}
.gap {
	margin-top: 30rpx;
}
.gap1 {
	margin-top: 200rpx;
}
.gap4{
	margin-top: 200rpx;
	margin-bottom: 200rpx;
}
.gap2 {
	margin-top: 500rpx;
}
.gap3{
	margin-top: 1rpx;
}
.scanListGap {
	margin-top: 40rpx;
	height: 2000rpx;
}
.machineBtn{
	margin-left: 20rpx;
}
.updateData{
	margin-top: 10rpx;
	display: flex;
	font-size: 30rpx;
	color: #666666;
}
.updateData button{
	height: 40rpx;
	font-size: 10rpx;
}
.input-contain{
	width: 600rpx;
	max-height: 600rpx;
	margin-top: 20rpx;
}
.list-item{
	display: flex;
	flex-direction: row;
	align-items: center;
	margin-bottom: 30rpx;
	width: 570rpx;
}
.list-item text{
	margin-right: 5rpx;
}
// 滚动条样式
	/deep/ ::-webkit-scrollbar {
		/*滚动条整体样式*/
		width: 10px !important;
		height: 1px !important;
		overflow: auto !important;
		background: #ccc !important;
		-webkit-appearance: auto !important;
		display: block;
	}

	/deep/ ::-webkit-scrollbar-thumb {
		/*滚动条里面小方块*/
		// border-radius: 10px !important;
		box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2) !important;
		background: #747474 !important;
	}

	/deep/ ::-webkit-scrollbar-track {
		/*滚动条里面轨道*/
		// box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2) !important;
		// border-radius: 10px !important;
		background: #FFFFFF !important;
	}
	
	/*table样式梳理*/
	.tableHeader{
	  display: flex;
	}
	.tableHeaderId{
	  width: 85rpx;
	  height: 70rpx;
	  background-color:#F4F6FF ;
	  border-radius: 20rpx 0 0 0;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  font-size: 26rpx;
	  font-weight: bold;
	  color: #333333;
	  border: 1rpx solid #DDE2FA;
	}
	.tableHeaderName{
	  width: 230rpx;
	  height: 70rpx;
	  background-color: #F4F6FF;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  font-size: 26rpx;
	  font-weight: bold;
	  color: #333333;
	  border: 1rpx solid #DDE2FA;
	  overflow: hidden;
	}
	.tableHeaderItem{
	  width: 168rpx;
	  height: 70rpx;
	  background-color: #F4F6FF;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  font-size: 26rpx;
	  font-weight: bold;
	  color: #333333;
	  border-radius: 0 20rpx 0 0;
	  border: 1rpx solid #DDE2FA;
	}
	.tableContent{
	  display: flex;
	}
	.tableContentId{
	  width: 86rpx;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  min-height: 108rpx;
	  background-color:#F8FCFF;
	  border: 1rpx solid #DDE2FA;
	}
	.tableContentName{
	  width: 230rpx;
	  // height: 108rpx;
	  font-size: 26rpx;
	  color: #333333;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  border: 1rpx solid #DDE2FA;
	  overflow: hidden; //超出部分隐藏
	  -webkit-line-clamp: 2; //显示几行
	  text-overflow: ellipsis; //超出部分显示省略号
	}
	.tabledescript{
		width: 230rpx;
		height: 108rpx;
		overflow: hidden; //超出部分隐藏
		-webkit-line-clamp: 3; //显示几行
		text-overflow: ellipsis; //超出部分显示省略号
		display: -webkit-box; //将对象作为弹性伸缩盒子模型显示
		-webkit-box-orient: vertical; //设置或检索伸缩盒对象的子元素的排列方式 纵向
	}
	.tableContentRight{
	  width: 173rpx;
	  font-size: 26rpx;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  // flex-direction: column;
	  flex-wrap: wrap;
	  border: 1rpx solid #DDE2FA;
	}
	.emsScanclass{
		width: 1000rpx;
		display: flex;
		flex-direction: column;
		white-space:normal; 
		word-break:break-all; 
		word-warp:break-word;
	}
	.cncJobnumber{
		width: 100%;
		display: flex;
		flex-direction: column;
		// align-items: center;
		margin-top: 10px;
	}
	.cncclass{
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}
</style>
